src/sqlite3.c
author Hernâni Marques <hernani@pep.foundation>
Wed, 27 Jun 2018 00:52:09 +0200
changeset 2771 b0c0d39f643d
parent 1912 b2f4e198adef
child 3192 8797e99f7ab2
permissions -rw-r--r--
typos (by reading for IETF)
     1 /******************************************************************************
     2 ** This file is an amalgamation of many separate C source files from SQLite
     3 ** version 3.19.3.  By combining all the individual C code files into this
     4 ** single large file, the entire code can be compiled as a single translation
     5 ** unit.  This allows many compilers to do optimizations that would not be
     6 ** possible if the files were compiled separately.  Performance improvements
     7 ** of 5% or more are commonly seen when SQLite is compiled as a single
     8 ** translation unit.
     9 **
    10 ** This file is all you need to compile SQLite.  To use SQLite in other
    11 ** programs, you need this file and the "sqlite3.h" header file that defines
    12 ** the programming interface to the SQLite library.  (If you do not have
    13 ** the "sqlite3.h" header file at hand, you will find a copy embedded within
    14 ** the text of this file.  Search for "Begin file sqlite3.h" to find the start
    15 ** of the embedded sqlite3.h header file.) Additional code files may be needed
    16 ** if you want a wrapper to interface SQLite with your choice of programming
    17 ** language. The code for the "sqlite3" command-line shell is also in a
    18 ** separate file. This file contains only code for the core SQLite library.
    19 */
    20 #define SQLITE_CORE 1
    21 #define SQLITE_AMALGAMATION 1
    22 #ifndef SQLITE_PRIVATE
    23 # define SQLITE_PRIVATE static
    24 #endif
    25 /************** Begin file sqliteInt.h ***************************************/
    26 /*
    27 ** 2001 September 15
    28 **
    29 ** The author disclaims copyright to this source code.  In place of
    30 ** a legal notice, here is a blessing:
    31 **
    32 **    May you do good and not evil.
    33 **    May you find forgiveness for yourself and forgive others.
    34 **    May you share freely, never taking more than you give.
    35 **
    36 *************************************************************************
    37 ** Internal interface definitions for SQLite.
    38 **
    39 */
    40 #ifndef SQLITEINT_H
    41 #define SQLITEINT_H
    42 
    43 /* Special Comments:
    44 **
    45 ** Some comments have special meaning to the tools that measure test
    46 ** coverage:
    47 **
    48 **    NO_TEST                     - The branches on this line are not
    49 **                                  measured by branch coverage.  This is
    50 **                                  used on lines of code that actually
    51 **                                  implement parts of coverage testing.
    52 **
    53 **    OPTIMIZATION-IF-TRUE        - This branch is allowed to alway be false
    54 **                                  and the correct answer is still obtained,
    55 **                                  though perhaps more slowly.
    56 **
    57 **    OPTIMIZATION-IF-FALSE       - This branch is allowed to alway be true
    58 **                                  and the correct answer is still obtained,
    59 **                                  though perhaps more slowly.
    60 **
    61 **    PREVENTS-HARMLESS-OVERREAD  - This branch prevents a buffer overread
    62 **                                  that would be harmless and undetectable
    63 **                                  if it did occur.  
    64 **
    65 ** In all cases, the special comment must be enclosed in the usual
    66 ** slash-asterisk...asterisk-slash comment marks, with no spaces between the 
    67 ** asterisks and the comment text.
    68 */
    69 
    70 /*
    71 ** Make sure the Tcl calling convention macro is defined.  This macro is
    72 ** only used by test code and Tcl integration code.
    73 */
    74 #ifndef SQLITE_TCLAPI
    75 #  define SQLITE_TCLAPI
    76 #endif
    77 
    78 /*
    79 ** Make sure that rand_s() is available on Windows systems with MSVC 2005
    80 ** or higher.
    81 */
    82 #if defined(_MSC_VER) && _MSC_VER>=1400
    83 #  define _CRT_RAND_S
    84 #endif
    85 
    86 /*
    87 ** Include the header file used to customize the compiler options for MSVC.
    88 ** This should be done first so that it can successfully prevent spurious
    89 ** compiler warnings due to subsequent content in this file and other files
    90 ** that are included by this file.
    91 */
    92 /************** Include msvc.h in the middle of sqliteInt.h ******************/
    93 /************** Begin file msvc.h ********************************************/
    94 /*
    95 ** 2015 January 12
    96 **
    97 ** The author disclaims copyright to this source code.  In place of
    98 ** a legal notice, here is a blessing:
    99 **
   100 **    May you do good and not evil.
   101 **    May you find forgiveness for yourself and forgive others.
   102 **    May you share freely, never taking more than you give.
   103 **
   104 ******************************************************************************
   105 **
   106 ** This file contains code that is specific to MSVC.
   107 */
   108 #ifndef SQLITE_MSVC_H
   109 #define SQLITE_MSVC_H
   110 
   111 #if defined(_MSC_VER)
   112 #pragma warning(disable : 4054)
   113 #pragma warning(disable : 4055)
   114 #pragma warning(disable : 4100)
   115 #pragma warning(disable : 4127)
   116 #pragma warning(disable : 4130)
   117 #pragma warning(disable : 4152)
   118 #pragma warning(disable : 4189)
   119 #pragma warning(disable : 4206)
   120 #pragma warning(disable : 4210)
   121 #pragma warning(disable : 4232)
   122 #pragma warning(disable : 4244)
   123 #pragma warning(disable : 4305)
   124 #pragma warning(disable : 4306)
   125 #pragma warning(disable : 4702)
   126 #pragma warning(disable : 4706)
   127 #endif /* defined(_MSC_VER) */
   128 
   129 #endif /* SQLITE_MSVC_H */
   130 
   131 /************** End of msvc.h ************************************************/
   132 /************** Continuing where we left off in sqliteInt.h ******************/
   133 
   134 /*
   135 ** Special setup for VxWorks
   136 */
   137 /************** Include vxworks.h in the middle of sqliteInt.h ***************/
   138 /************** Begin file vxworks.h *****************************************/
   139 /*
   140 ** 2015-03-02
   141 **
   142 ** The author disclaims copyright to this source code.  In place of
   143 ** a legal notice, here is a blessing:
   144 **
   145 **    May you do good and not evil.
   146 **    May you find forgiveness for yourself and forgive others.
   147 **    May you share freely, never taking more than you give.
   148 **
   149 ******************************************************************************
   150 **
   151 ** This file contains code that is specific to Wind River's VxWorks
   152 */
   153 #if defined(__RTP__) || defined(_WRS_KERNEL)
   154 /* This is VxWorks.  Set up things specially for that OS
   155 */
   156 #include <vxWorks.h>
   157 #include <pthread.h>  /* amalgamator: dontcache */
   158 #define OS_VXWORKS 1
   159 #define SQLITE_OS_OTHER 0
   160 #define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
   161 #define SQLITE_OMIT_LOAD_EXTENSION 1
   162 #define SQLITE_ENABLE_LOCKING_STYLE 0
   163 #define HAVE_UTIME 1
   164 #else
   165 /* This is not VxWorks. */
   166 #define OS_VXWORKS 0
   167 #define HAVE_FCHOWN 1
   168 #define HAVE_READLINK 1
   169 #define HAVE_LSTAT 1
   170 #endif /* defined(_WRS_KERNEL) */
   171 
   172 /************** End of vxworks.h *********************************************/
   173 /************** Continuing where we left off in sqliteInt.h ******************/
   174 
   175 /*
   176 ** These #defines should enable >2GB file support on POSIX if the
   177 ** underlying operating system supports it.  If the OS lacks
   178 ** large file support, or if the OS is windows, these should be no-ops.
   179 **
   180 ** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any
   181 ** system #includes.  Hence, this block of code must be the very first
   182 ** code in all source files.
   183 **
   184 ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
   185 ** on the compiler command line.  This is necessary if you are compiling
   186 ** on a recent machine (ex: Red Hat 7.2) but you want your code to work
   187 ** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2
   188 ** without this option, LFS is enable.  But LFS does not exist in the kernel
   189 ** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary
   190 ** portability you should omit LFS.
   191 **
   192 ** The previous paragraph was written in 2005.  (This paragraph is written
   193 ** on 2008-11-28.) These days, all Linux kernels support large files, so
   194 ** you should probably leave LFS enabled.  But some embedded platforms might
   195 ** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
   196 **
   197 ** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.
   198 */
   199 #ifndef SQLITE_DISABLE_LFS
   200 # define _LARGE_FILE       1
   201 # ifndef _FILE_OFFSET_BITS
   202 #   define _FILE_OFFSET_BITS 64
   203 # endif
   204 # define _LARGEFILE_SOURCE 1
   205 #endif
   206 
   207 /* The GCC_VERSION and MSVC_VERSION macros are used to
   208 ** conditionally include optimizations for each of these compilers.  A
   209 ** value of 0 means that compiler is not being used.  The
   210 ** SQLITE_DISABLE_INTRINSIC macro means do not use any compiler-specific
   211 ** optimizations, and hence set all compiler macros to 0
   212 **
   213 ** There was once also a CLANG_VERSION macro.  However, we learn that the
   214 ** version numbers in clang are for "marketing" only and are inconsistent
   215 ** and unreliable.  Fortunately, all versions of clang also recognize the
   216 ** gcc version numbers and have reasonable settings for gcc version numbers,
   217 ** so the GCC_VERSION macro will be set to a correct non-zero value even
   218 ** when compiling with clang.
   219 */
   220 #if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)
   221 # define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
   222 #else
   223 # define GCC_VERSION 0
   224 #endif
   225 #if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)
   226 # define MSVC_VERSION _MSC_VER
   227 #else
   228 # define MSVC_VERSION 0
   229 #endif
   230 
   231 /* Needed for various definitions... */
   232 #if defined(__GNUC__) && !defined(_GNU_SOURCE)
   233 # define _GNU_SOURCE
   234 #endif
   235 
   236 #if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
   237 # define _BSD_SOURCE
   238 #endif
   239 
   240 /*
   241 ** For MinGW, check to see if we can include the header file containing its
   242 ** version information, among other things.  Normally, this internal MinGW
   243 ** header file would [only] be included automatically by other MinGW header
   244 ** files; however, the contained version information is now required by this
   245 ** header file to work around binary compatibility issues (see below) and
   246 ** this is the only known way to reliably obtain it.  This entire #if block
   247 ** would be completely unnecessary if there was any other way of detecting
   248 ** MinGW via their preprocessor (e.g. if they customized their GCC to define
   249 ** some MinGW-specific macros).  When compiling for MinGW, either the
   250 ** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be
   251 ** defined; otherwise, detection of conditions specific to MinGW will be
   252 ** disabled.
   253 */
   254 #if defined(_HAVE_MINGW_H)
   255 # include "mingw.h"
   256 #elif defined(_HAVE__MINGW_H)
   257 # include "_mingw.h"
   258 #endif
   259 
   260 /*
   261 ** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T
   262 ** define is required to maintain binary compatibility with the MSVC runtime
   263 ** library in use (e.g. for Windows XP).
   264 */
   265 #if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \
   266     defined(_WIN32) && !defined(_WIN64) && \
   267     defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
   268     defined(__MSVCRT__)
   269 # define _USE_32BIT_TIME_T
   270 #endif
   271 
   272 /* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear
   273 ** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for
   274 ** MinGW.
   275 */
   276 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
   277 /************** Begin file sqlite3.h *****************************************/
   278 /*
   279 ** 2001 September 15
   280 **
   281 ** The author disclaims copyright to this source code.  In place of
   282 ** a legal notice, here is a blessing:
   283 **
   284 **    May you do good and not evil.
   285 **    May you find forgiveness for yourself and forgive others.
   286 **    May you share freely, never taking more than you give.
   287 **
   288 *************************************************************************
   289 ** This header file defines the interface that the SQLite library
   290 ** presents to client programs.  If a C-function, structure, datatype,
   291 ** or constant definition does not appear in this file, then it is
   292 ** not a published API of SQLite, is subject to change without
   293 ** notice, and should not be referenced by programs that use SQLite.
   294 **
   295 ** Some of the definitions that are in this file are marked as
   296 ** "experimental".  Experimental interfaces are normally new
   297 ** features recently added to SQLite.  We do not anticipate changes
   298 ** to experimental interfaces but reserve the right to make minor changes
   299 ** if experience from use "in the wild" suggest such changes are prudent.
   300 **
   301 ** The official C-language API documentation for SQLite is derived
   302 ** from comments in this file.  This file is the authoritative source
   303 ** on how SQLite interfaces are supposed to operate.
   304 **
   305 ** The name of this file under configuration management is "sqlite.h.in".
   306 ** The makefile makes some minor changes to this file (such as inserting
   307 ** the version number) and changes its name to "sqlite3.h" as
   308 ** part of the build process.
   309 */
   310 #ifndef SQLITE3_H
   311 #define SQLITE3_H
   312 #include <stdarg.h>     /* Needed for the definition of va_list */
   313 
   314 /*
   315 ** Make sure we can call this stuff from C++.
   316 */
   317 #if 0
   318 extern "C" {
   319 #endif
   320 
   321 
   322 /*
   323 ** Provide the ability to override linkage features of the interface.
   324 */
   325 #ifndef SQLITE_EXTERN
   326 # define SQLITE_EXTERN extern
   327 #endif
   328 #ifndef SQLITE_API
   329 # define SQLITE_API
   330 #endif
   331 #ifndef SQLITE_CDECL
   332 # define SQLITE_CDECL
   333 #endif
   334 #ifndef SQLITE_APICALL
   335 # define SQLITE_APICALL
   336 #endif
   337 #ifndef SQLITE_STDCALL
   338 # define SQLITE_STDCALL SQLITE_APICALL
   339 #endif
   340 #ifndef SQLITE_CALLBACK
   341 # define SQLITE_CALLBACK
   342 #endif
   343 #ifndef SQLITE_SYSAPI
   344 # define SQLITE_SYSAPI
   345 #endif
   346 
   347 /*
   348 ** These no-op macros are used in front of interfaces to mark those
   349 ** interfaces as either deprecated or experimental.  New applications
   350 ** should not use deprecated interfaces - they are supported for backwards
   351 ** compatibility only.  Application writers should be aware that
   352 ** experimental interfaces are subject to change in point releases.
   353 **
   354 ** These macros used to resolve to various kinds of compiler magic that
   355 ** would generate warning messages when they were used.  But that
   356 ** compiler magic ended up generating such a flurry of bug reports
   357 ** that we have taken it all out and gone back to using simple
   358 ** noop macros.
   359 */
   360 #define SQLITE_DEPRECATED
   361 #define SQLITE_EXPERIMENTAL
   362 
   363 /*
   364 ** Ensure these symbols were not defined by some previous header file.
   365 */
   366 #ifdef SQLITE_VERSION
   367 # undef SQLITE_VERSION
   368 #endif
   369 #ifdef SQLITE_VERSION_NUMBER
   370 # undef SQLITE_VERSION_NUMBER
   371 #endif
   372 
   373 /*
   374 ** CAPI3REF: Compile-Time Library Version Numbers
   375 **
   376 ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
   377 ** evaluates to a string literal that is the SQLite version in the
   378 ** format "X.Y.Z" where X is the major version number (always 3 for
   379 ** SQLite3) and Y is the minor version number and Z is the release number.)^
   380 ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
   381 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
   382 ** numbers used in [SQLITE_VERSION].)^
   383 ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
   384 ** be larger than the release from which it is derived.  Either Y will
   385 ** be held constant and Z will be incremented or else Y will be incremented
   386 ** and Z will be reset to zero.
   387 **
   388 ** Since [version 3.6.18] ([dateof:3.6.18]), 
   389 ** SQLite source code has been stored in the
   390 ** <a href="http://www.fossil-scm.org/">Fossil configuration management
   391 ** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to
   392 ** a string which identifies a particular check-in of SQLite
   393 ** within its configuration management system.  ^The SQLITE_SOURCE_ID
   394 ** string contains the date and time of the check-in (UTC) and a SHA1
   395 ** or SHA3-256 hash of the entire source tree.
   396 **
   397 ** See also: [sqlite3_libversion()],
   398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   399 ** [sqlite_version()] and [sqlite_source_id()].
   400 */
   401 #define SQLITE_VERSION        "3.19.3"
   402 #define SQLITE_VERSION_NUMBER 3019003
   403 #define SQLITE_SOURCE_ID      "2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b"
   404 
   405 /*
   406 ** CAPI3REF: Run-Time Library Version Numbers
   407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
   408 **
   409 ** These interfaces provide the same information as the [SQLITE_VERSION],
   410 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
   411 ** but are associated with the library instead of the header file.  ^(Cautious
   412 ** programmers might include assert() statements in their application to
   413 ** verify that values returned by these interfaces match the macros in
   414 ** the header, and thus ensure that the application is
   415 ** compiled with matching library and header files.
   416 **
   417 ** <blockquote><pre>
   418 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
   419 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
   420 ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
   421 ** </pre></blockquote>)^
   422 **
   423 ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
   424 ** macro.  ^The sqlite3_libversion() function returns a pointer to the
   425 ** to the sqlite3_version[] string constant.  The sqlite3_libversion()
   426 ** function is provided for use in DLLs since DLL users usually do not have
   427 ** direct access to string constants within the DLL.  ^The
   428 ** sqlite3_libversion_number() function returns an integer equal to
   429 ** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns 
   430 ** a pointer to a string constant whose value is the same as the 
   431 ** [SQLITE_SOURCE_ID] C preprocessor macro.
   432 **
   433 ** See also: [sqlite_version()] and [sqlite_source_id()].
   434 */
   435 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
   436 SQLITE_API const char *sqlite3_libversion(void);
   437 SQLITE_API const char *sqlite3_sourceid(void);
   438 SQLITE_API int sqlite3_libversion_number(void);
   439 
   440 /*
   441 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
   442 **
   443 ** ^The sqlite3_compileoption_used() function returns 0 or 1 
   444 ** indicating whether the specified option was defined at 
   445 ** compile time.  ^The SQLITE_ prefix may be omitted from the 
   446 ** option name passed to sqlite3_compileoption_used().  
   447 **
   448 ** ^The sqlite3_compileoption_get() function allows iterating
   449 ** over the list of options that were defined at compile time by
   450 ** returning the N-th compile time option string.  ^If N is out of range,
   451 ** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ 
   452 ** prefix is omitted from any strings returned by 
   453 ** sqlite3_compileoption_get().
   454 **
   455 ** ^Support for the diagnostic functions sqlite3_compileoption_used()
   456 ** and sqlite3_compileoption_get() may be omitted by specifying the 
   457 ** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
   458 **
   459 ** See also: SQL functions [sqlite_compileoption_used()] and
   460 ** [sqlite_compileoption_get()] and the [compile_options pragma].
   461 */
   462 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
   463 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
   464 SQLITE_API const char *sqlite3_compileoption_get(int N);
   465 #endif
   466 
   467 /*
   468 ** CAPI3REF: Test To See If The Library Is Threadsafe
   469 **
   470 ** ^The sqlite3_threadsafe() function returns zero if and only if
   471 ** SQLite was compiled with mutexing code omitted due to the
   472 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
   473 **
   474 ** SQLite can be compiled with or without mutexes.  When
   475 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
   476 ** are enabled and SQLite is threadsafe.  When the
   477 ** [SQLITE_THREADSAFE] macro is 0, 
   478 ** the mutexes are omitted.  Without the mutexes, it is not safe
   479 ** to use SQLite concurrently from more than one thread.
   480 **
   481 ** Enabling mutexes incurs a measurable performance penalty.
   482 ** So if speed is of utmost importance, it makes sense to disable
   483 ** the mutexes.  But for maximum safety, mutexes should be enabled.
   484 ** ^The default behavior is for mutexes to be enabled.
   485 **
   486 ** This interface can be used by an application to make sure that the
   487 ** version of SQLite that it is linking against was compiled with
   488 ** the desired setting of the [SQLITE_THREADSAFE] macro.
   489 **
   490 ** This interface only reports on the compile-time mutex setting
   491 ** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
   492 ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
   493 ** can be fully or partially disabled using a call to [sqlite3_config()]
   494 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
   495 ** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
   496 ** sqlite3_threadsafe() function shows only the compile-time setting of
   497 ** thread safety, not any run-time changes to that setting made by
   498 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
   499 ** is unchanged by calls to sqlite3_config().)^
   500 **
   501 ** See the [threading mode] documentation for additional information.
   502 */
   503 SQLITE_API int sqlite3_threadsafe(void);
   504 
   505 /*
   506 ** CAPI3REF: Database Connection Handle
   507 ** KEYWORDS: {database connection} {database connections}
   508 **
   509 ** Each open SQLite database is represented by a pointer to an instance of
   510 ** the opaque structure named "sqlite3".  It is useful to think of an sqlite3
   511 ** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and
   512 ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
   513 ** and [sqlite3_close_v2()] are its destructors.  There are many other
   514 ** interfaces (such as
   515 ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
   516 ** [sqlite3_busy_timeout()] to name but three) that are methods on an
   517 ** sqlite3 object.
   518 */
   519 typedef struct sqlite3 sqlite3;
   520 
   521 /*
   522 ** CAPI3REF: 64-Bit Integer Types
   523 ** KEYWORDS: sqlite_int64 sqlite_uint64
   524 **
   525 ** Because there is no cross-platform way to specify 64-bit integer types
   526 ** SQLite includes typedefs for 64-bit signed and unsigned integers.
   527 **
   528 ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
   529 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
   530 ** compatibility only.
   531 **
   532 ** ^The sqlite3_int64 and sqlite_int64 types can store integer values
   533 ** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
   534 ** sqlite3_uint64 and sqlite_uint64 types can store integer values 
   535 ** between 0 and +18446744073709551615 inclusive.
   536 */
   537 #ifdef SQLITE_INT64_TYPE
   538   typedef SQLITE_INT64_TYPE sqlite_int64;
   539 # ifdef SQLITE_UINT64_TYPE
   540     typedef SQLITE_UINT64_TYPE sqlite_uint64;
   541 # else  
   542     typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
   543 # endif
   544 #elif defined(_MSC_VER) || defined(__BORLANDC__)
   545   typedef __int64 sqlite_int64;
   546   typedef unsigned __int64 sqlite_uint64;
   547 #else
   548   typedef long long int sqlite_int64;
   549   typedef unsigned long long int sqlite_uint64;
   550 #endif
   551 typedef sqlite_int64 sqlite3_int64;
   552 typedef sqlite_uint64 sqlite3_uint64;
   553 
   554 /*
   555 ** If compiling for a processor that lacks floating point support,
   556 ** substitute integer for floating-point.
   557 */
   558 #ifdef SQLITE_OMIT_FLOATING_POINT
   559 # define double sqlite3_int64
   560 #endif
   561 
   562 /*
   563 ** CAPI3REF: Closing A Database Connection
   564 ** DESTRUCTOR: sqlite3
   565 **
   566 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
   567 ** for the [sqlite3] object.
   568 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
   569 ** the [sqlite3] object is successfully destroyed and all associated
   570 ** resources are deallocated.
   571 **
   572 ** ^If the database connection is associated with unfinalized prepared
   573 ** statements or unfinished sqlite3_backup objects then sqlite3_close()
   574 ** will leave the database connection open and return [SQLITE_BUSY].
   575 ** ^If sqlite3_close_v2() is called with unfinalized prepared statements
   576 ** and/or unfinished sqlite3_backups, then the database connection becomes
   577 ** an unusable "zombie" which will automatically be deallocated when the
   578 ** last prepared statement is finalized or the last sqlite3_backup is
   579 ** finished.  The sqlite3_close_v2() interface is intended for use with
   580 ** host languages that are garbage collected, and where the order in which
   581 ** destructors are called is arbitrary.
   582 **
   583 ** Applications should [sqlite3_finalize | finalize] all [prepared statements],
   584 ** [sqlite3_blob_close | close] all [BLOB handles], and 
   585 ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
   586 ** with the [sqlite3] object prior to attempting to close the object.  ^If
   587 ** sqlite3_close_v2() is called on a [database connection] that still has
   588 ** outstanding [prepared statements], [BLOB handles], and/or
   589 ** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation
   590 ** of resources is deferred until all [prepared statements], [BLOB handles],
   591 ** and [sqlite3_backup] objects are also destroyed.
   592 **
   593 ** ^If an [sqlite3] object is destroyed while a transaction is open,
   594 ** the transaction is automatically rolled back.
   595 **
   596 ** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]
   597 ** must be either a NULL
   598 ** pointer or an [sqlite3] object pointer obtained
   599 ** from [sqlite3_open()], [sqlite3_open16()], or
   600 ** [sqlite3_open_v2()], and not previously closed.
   601 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
   602 ** argument is a harmless no-op.
   603 */
   604 SQLITE_API int sqlite3_close(sqlite3*);
   605 SQLITE_API int sqlite3_close_v2(sqlite3*);
   606 
   607 /*
   608 ** The type for a callback function.
   609 ** This is legacy and deprecated.  It is included for historical
   610 ** compatibility and is not documented.
   611 */
   612 typedef int (*sqlite3_callback)(void*,int,char**, char**);
   613 
   614 /*
   615 ** CAPI3REF: One-Step Query Execution Interface
   616 ** METHOD: sqlite3
   617 **
   618 ** The sqlite3_exec() interface is a convenience wrapper around
   619 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
   620 ** that allows an application to run multiple statements of SQL
   621 ** without having to use a lot of C code. 
   622 **
   623 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
   624 ** semicolon-separate SQL statements passed into its 2nd argument,
   625 ** in the context of the [database connection] passed in as its 1st
   626 ** argument.  ^If the callback function of the 3rd argument to
   627 ** sqlite3_exec() is not NULL, then it is invoked for each result row
   628 ** coming out of the evaluated SQL statements.  ^The 4th argument to
   629 ** sqlite3_exec() is relayed through to the 1st argument of each
   630 ** callback invocation.  ^If the callback pointer to sqlite3_exec()
   631 ** is NULL, then no callback is ever invoked and result rows are
   632 ** ignored.
   633 **
   634 ** ^If an error occurs while evaluating the SQL statements passed into
   635 ** sqlite3_exec(), then execution of the current statement stops and
   636 ** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()
   637 ** is not NULL then any error message is written into memory obtained
   638 ** from [sqlite3_malloc()] and passed back through the 5th parameter.
   639 ** To avoid memory leaks, the application should invoke [sqlite3_free()]
   640 ** on error message strings returned through the 5th parameter of
   641 ** sqlite3_exec() after the error message string is no longer needed.
   642 ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
   643 ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
   644 ** NULL before returning.
   645 **
   646 ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
   647 ** routine returns SQLITE_ABORT without invoking the callback again and
   648 ** without running any subsequent SQL statements.
   649 **
   650 ** ^The 2nd argument to the sqlite3_exec() callback function is the
   651 ** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()
   652 ** callback is an array of pointers to strings obtained as if from
   653 ** [sqlite3_column_text()], one for each column.  ^If an element of a
   654 ** result row is NULL then the corresponding string pointer for the
   655 ** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the
   656 ** sqlite3_exec() callback is an array of pointers to strings where each
   657 ** entry represents the name of corresponding result column as obtained
   658 ** from [sqlite3_column_name()].
   659 **
   660 ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
   661 ** to an empty string, or a pointer that contains only whitespace and/or 
   662 ** SQL comments, then no SQL statements are evaluated and the database
   663 ** is not changed.
   664 **
   665 ** Restrictions:
   666 **
   667 ** <ul>
   668 ** <li> The application must ensure that the 1st parameter to sqlite3_exec()
   669 **      is a valid and open [database connection].
   670 ** <li> The application must not close the [database connection] specified by
   671 **      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
   672 ** <li> The application must not modify the SQL statement text passed into
   673 **      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
   674 ** </ul>
   675 */
   676 SQLITE_API int sqlite3_exec(
   677   sqlite3*,                                  /* An open database */
   678   const char *sql,                           /* SQL to be evaluated */
   679   int (*callback)(void*,int,char**,char**),  /* Callback function */
   680   void *,                                    /* 1st argument to callback */
   681   char **errmsg                              /* Error msg written here */
   682 );
   683 
   684 /*
   685 ** CAPI3REF: Result Codes
   686 ** KEYWORDS: {result code definitions}
   687 **
   688 ** Many SQLite functions return an integer result code from the set shown
   689 ** here in order to indicate success or failure.
   690 **
   691 ** New error codes may be added in future versions of SQLite.
   692 **
   693 ** See also: [extended result code definitions]
   694 */
   695 #define SQLITE_OK           0   /* Successful result */
   696 /* beginning-of-error-codes */
   697 #define SQLITE_ERROR        1   /* SQL error or missing database */
   698 #define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
   699 #define SQLITE_PERM         3   /* Access permission denied */
   700 #define SQLITE_ABORT        4   /* Callback routine requested an abort */
   701 #define SQLITE_BUSY         5   /* The database file is locked */
   702 #define SQLITE_LOCKED       6   /* A table in the database is locked */
   703 #define SQLITE_NOMEM        7   /* A malloc() failed */
   704 #define SQLITE_READONLY     8   /* Attempt to write a readonly database */
   705 #define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
   706 #define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
   707 #define SQLITE_CORRUPT     11   /* The database disk image is malformed */
   708 #define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
   709 #define SQLITE_FULL        13   /* Insertion failed because database is full */
   710 #define SQLITE_CANTOPEN    14   /* Unable to open the database file */
   711 #define SQLITE_PROTOCOL    15   /* Database lock protocol error */
   712 #define SQLITE_EMPTY       16   /* Database is empty */
   713 #define SQLITE_SCHEMA      17   /* The database schema changed */
   714 #define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
   715 #define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
   716 #define SQLITE_MISMATCH    20   /* Data type mismatch */
   717 #define SQLITE_MISUSE      21   /* Library used incorrectly */
   718 #define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
   719 #define SQLITE_AUTH        23   /* Authorization denied */
   720 #define SQLITE_FORMAT      24   /* Auxiliary database format error */
   721 #define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
   722 #define SQLITE_NOTADB      26   /* File opened that is not a database file */
   723 #define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */
   724 #define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */
   725 #define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
   726 #define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
   727 /* end-of-error-codes */
   728 
   729 /*
   730 ** CAPI3REF: Extended Result Codes
   731 ** KEYWORDS: {extended result code definitions}
   732 **
   733 ** In its default configuration, SQLite API routines return one of 30 integer
   734 ** [result codes].  However, experience has shown that many of
   735 ** these result codes are too coarse-grained.  They do not provide as
   736 ** much information about problems as programmers might like.  In an effort to
   737 ** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]
   738 ** and later) include
   739 ** support for additional result codes that provide more detailed information
   740 ** about errors. These [extended result codes] are enabled or disabled
   741 ** on a per database connection basis using the
   742 ** [sqlite3_extended_result_codes()] API.  Or, the extended code for
   743 ** the most recent error can be obtained using
   744 ** [sqlite3_extended_errcode()].
   745 */
   746 #define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
   747 #define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))
   748 #define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))
   749 #define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))
   750 #define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))
   751 #define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))
   752 #define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))
   753 #define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))
   754 #define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))
   755 #define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))
   756 #define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))
   757 #define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))
   758 #define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))
   759 #define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
   760 #define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
   761 #define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
   762 #define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
   763 #define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
   764 #define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
   765 #define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
   766 #define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))
   767 #define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))
   768 #define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))
   769 #define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
   770 #define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
   771 #define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
   772 #define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
   773 #define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
   774 #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   775 #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   776 #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   777 #define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
   778 #define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
   779 #define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
   780 #define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
   781 #define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
   782 #define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
   783 #define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
   784 #define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
   785 #define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
   786 #define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
   787 #define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))
   788 #define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))
   789 #define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))
   790 #define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))
   791 #define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))
   792 #define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))
   793 #define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))
   794 #define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
   795 #define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
   796 #define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
   797 #define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
   798 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
   799 #define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
   800 #define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
   801 #define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))
   802 
   803 /*
   804 ** CAPI3REF: Flags For File Open Operations
   805 **
   806 ** These bit values are intended for use in the
   807 ** 3rd parameter to the [sqlite3_open_v2()] interface and
   808 ** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
   809 */
   810 #define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */
   811 #define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */
   812 #define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */
   813 #define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */
   814 #define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */
   815 #define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */
   816 #define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */
   817 #define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */
   818 #define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */
   819 #define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */
   820 #define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */
   821 #define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */
   822 #define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */
   823 #define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */
   824 #define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */
   825 #define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */
   826 #define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
   827 #define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
   828 #define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
   829 #define SQLITE_OPEN_WAL              0x00080000  /* VFS only */
   830 
   831 /* Reserved:                         0x00F00000 */
   832 
   833 /*
   834 ** CAPI3REF: Device Characteristics
   835 **
   836 ** The xDeviceCharacteristics method of the [sqlite3_io_methods]
   837 ** object returns an integer which is a vector of these
   838 ** bit values expressing I/O characteristics of the mass storage
   839 ** device that holds the file that the [sqlite3_io_methods]
   840 ** refers to.
   841 **
   842 ** The SQLITE_IOCAP_ATOMIC property means that all writes of
   843 ** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
   844 ** mean that writes of blocks that are nnn bytes in size and
   845 ** are aligned to an address which is an integer multiple of
   846 ** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
   847 ** that when data is appended to a file, the data is appended
   848 ** first then the size of the file is extended, never the other
   849 ** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
   850 ** information is written to disk in the same order as calls
   851 ** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
   852 ** after reboot following a crash or power loss, the only bytes in a
   853 ** file that were written at the application level might have changed
   854 ** and that adjacent bytes, even bytes within the same sector are
   855 ** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
   856 ** flag indicates that a file cannot be deleted when open.  The
   857 ** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
   858 ** read-only media and cannot be changed even by processes with
   859 ** elevated privileges.
   860 */
   861 #define SQLITE_IOCAP_ATOMIC                 0x00000001
   862 #define SQLITE_IOCAP_ATOMIC512              0x00000002
   863 #define SQLITE_IOCAP_ATOMIC1K               0x00000004
   864 #define SQLITE_IOCAP_ATOMIC2K               0x00000008
   865 #define SQLITE_IOCAP_ATOMIC4K               0x00000010
   866 #define SQLITE_IOCAP_ATOMIC8K               0x00000020
   867 #define SQLITE_IOCAP_ATOMIC16K              0x00000040
   868 #define SQLITE_IOCAP_ATOMIC32K              0x00000080
   869 #define SQLITE_IOCAP_ATOMIC64K              0x00000100
   870 #define SQLITE_IOCAP_SAFE_APPEND            0x00000200
   871 #define SQLITE_IOCAP_SEQUENTIAL             0x00000400
   872 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800
   873 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000
   874 #define SQLITE_IOCAP_IMMUTABLE              0x00002000
   875 
   876 /*
   877 ** CAPI3REF: File Locking Levels
   878 **
   879 ** SQLite uses one of these integer values as the second
   880 ** argument to calls it makes to the xLock() and xUnlock() methods
   881 ** of an [sqlite3_io_methods] object.
   882 */
   883 #define SQLITE_LOCK_NONE          0
   884 #define SQLITE_LOCK_SHARED        1
   885 #define SQLITE_LOCK_RESERVED      2
   886 #define SQLITE_LOCK_PENDING       3
   887 #define SQLITE_LOCK_EXCLUSIVE     4
   888 
   889 /*
   890 ** CAPI3REF: Synchronization Type Flags
   891 **
   892 ** When SQLite invokes the xSync() method of an
   893 ** [sqlite3_io_methods] object it uses a combination of
   894 ** these integer values as the second argument.
   895 **
   896 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
   897 ** sync operation only needs to flush data to mass storage.  Inode
   898 ** information need not be flushed. If the lower four bits of the flag
   899 ** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
   900 ** If the lower four bits equal SQLITE_SYNC_FULL, that means
   901 ** to use Mac OS X style fullsync instead of fsync().
   902 **
   903 ** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
   904 ** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
   905 ** settings.  The [synchronous pragma] determines when calls to the
   906 ** xSync VFS method occur and applies uniformly across all platforms.
   907 ** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
   908 ** energetic or rigorous or forceful the sync operations are and
   909 ** only make a difference on Mac OSX for the default SQLite code.
   910 ** (Third-party VFS implementations might also make the distinction
   911 ** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
   912 ** operating systems natively supported by SQLite, only Mac OSX
   913 ** cares about the difference.)
   914 */
   915 #define SQLITE_SYNC_NORMAL        0x00002
   916 #define SQLITE_SYNC_FULL          0x00003
   917 #define SQLITE_SYNC_DATAONLY      0x00010
   918 
   919 /*
   920 ** CAPI3REF: OS Interface Open File Handle
   921 **
   922 ** An [sqlite3_file] object represents an open file in the 
   923 ** [sqlite3_vfs | OS interface layer].  Individual OS interface
   924 ** implementations will
   925 ** want to subclass this object by appending additional fields
   926 ** for their own use.  The pMethods entry is a pointer to an
   927 ** [sqlite3_io_methods] object that defines methods for performing
   928 ** I/O operations on the open file.
   929 */
   930 typedef struct sqlite3_file sqlite3_file;
   931 struct sqlite3_file {
   932   const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
   933 };
   934 
   935 /*
   936 ** CAPI3REF: OS Interface File Virtual Methods Object
   937 **
   938 ** Every file opened by the [sqlite3_vfs.xOpen] method populates an
   939 ** [sqlite3_file] object (or, more commonly, a subclass of the
   940 ** [sqlite3_file] object) with a pointer to an instance of this object.
   941 ** This object defines the methods used to perform various operations
   942 ** against the open file represented by the [sqlite3_file] object.
   943 **
   944 ** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element 
   945 ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
   946 ** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The
   947 ** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
   948 ** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
   949 ** to NULL.
   950 **
   951 ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
   952 ** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().
   953 ** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]
   954 ** flag may be ORed in to indicate that only the data of the file
   955 ** and not its inode needs to be synced.
   956 **
   957 ** The integer values to xLock() and xUnlock() are one of
   958 ** <ul>
   959 ** <li> [SQLITE_LOCK_NONE],
   960 ** <li> [SQLITE_LOCK_SHARED],
   961 ** <li> [SQLITE_LOCK_RESERVED],
   962 ** <li> [SQLITE_LOCK_PENDING], or
   963 ** <li> [SQLITE_LOCK_EXCLUSIVE].
   964 ** </ul>
   965 ** xLock() increases the lock. xUnlock() decreases the lock.
   966 ** The xCheckReservedLock() method checks whether any database connection,
   967 ** either in this process or in some other process, is holding a RESERVED,
   968 ** PENDING, or EXCLUSIVE lock on the file.  It returns true
   969 ** if such a lock exists and false otherwise.
   970 **
   971 ** The xFileControl() method is a generic interface that allows custom
   972 ** VFS implementations to directly control an open file using the
   973 ** [sqlite3_file_control()] interface.  The second "op" argument is an
   974 ** integer opcode.  The third argument is a generic pointer intended to
   975 ** point to a structure that may contain arguments or space in which to
   976 ** write return values.  Potential uses for xFileControl() might be
   977 ** functions to enable blocking locks with timeouts, to change the
   978 ** locking strategy (for example to use dot-file locks), to inquire
   979 ** about the status of a lock, or to break stale locks.  The SQLite
   980 ** core reserves all opcodes less than 100 for its own use.
   981 ** A [file control opcodes | list of opcodes] less than 100 is available.
   982 ** Applications that define a custom xFileControl method should use opcodes
   983 ** greater than 100 to avoid conflicts.  VFS implementations should
   984 ** return [SQLITE_NOTFOUND] for file control opcodes that they do not
   985 ** recognize.
   986 **
   987 ** The xSectorSize() method returns the sector size of the
   988 ** device that underlies the file.  The sector size is the
   989 ** minimum write that can be performed without disturbing
   990 ** other bytes in the file.  The xDeviceCharacteristics()
   991 ** method returns a bit vector describing behaviors of the
   992 ** underlying device:
   993 **
   994 ** <ul>
   995 ** <li> [SQLITE_IOCAP_ATOMIC]
   996 ** <li> [SQLITE_IOCAP_ATOMIC512]
   997 ** <li> [SQLITE_IOCAP_ATOMIC1K]
   998 ** <li> [SQLITE_IOCAP_ATOMIC2K]
   999 ** <li> [SQLITE_IOCAP_ATOMIC4K]
  1000 ** <li> [SQLITE_IOCAP_ATOMIC8K]
  1001 ** <li> [SQLITE_IOCAP_ATOMIC16K]
  1002 ** <li> [SQLITE_IOCAP_ATOMIC32K]
  1003 ** <li> [SQLITE_IOCAP_ATOMIC64K]
  1004 ** <li> [SQLITE_IOCAP_SAFE_APPEND]
  1005 ** <li> [SQLITE_IOCAP_SEQUENTIAL]
  1006 ** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]
  1007 ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
  1008 ** <li> [SQLITE_IOCAP_IMMUTABLE]
  1009 ** </ul>
  1010 **
  1011 ** The SQLITE_IOCAP_ATOMIC property means that all writes of
  1012 ** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
  1013 ** mean that writes of blocks that are nnn bytes in size and
  1014 ** are aligned to an address which is an integer multiple of
  1015 ** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
  1016 ** that when data is appended to a file, the data is appended
  1017 ** first then the size of the file is extended, never the other
  1018 ** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
  1019 ** information is written to disk in the same order as calls
  1020 ** to xWrite().
  1021 **
  1022 ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
  1023 ** in the unread portions of the buffer with zeros.  A VFS that
  1024 ** fails to zero-fill short reads might seem to work.  However,
  1025 ** failure to zero-fill short reads will eventually lead to
  1026 ** database corruption.
  1027 */
  1028 typedef struct sqlite3_io_methods sqlite3_io_methods;
  1029 struct sqlite3_io_methods {
  1030   int iVersion;
  1031   int (*xClose)(sqlite3_file*);
  1032   int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
  1033   int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
  1034   int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
  1035   int (*xSync)(sqlite3_file*, int flags);
  1036   int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
  1037   int (*xLock)(sqlite3_file*, int);
  1038   int (*xUnlock)(sqlite3_file*, int);
  1039   int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
  1040   int (*xFileControl)(sqlite3_file*, int op, void *pArg);
  1041   int (*xSectorSize)(sqlite3_file*);
  1042   int (*xDeviceCharacteristics)(sqlite3_file*);
  1043   /* Methods above are valid for version 1 */
  1044   int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
  1045   int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
  1046   void (*xShmBarrier)(sqlite3_file*);
  1047   int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
  1048   /* Methods above are valid for version 2 */
  1049   int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
  1050   int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
  1051   /* Methods above are valid for version 3 */
  1052   /* Additional methods may be added in future releases */
  1053 };
  1054 
  1055 /*
  1056 ** CAPI3REF: Standard File Control Opcodes
  1057 ** KEYWORDS: {file control opcodes} {file control opcode}
  1058 **
  1059 ** These integer constants are opcodes for the xFileControl method
  1060 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
  1061 ** interface.
  1062 **
  1063 ** <ul>
  1064 ** <li>[[SQLITE_FCNTL_LOCKSTATE]]
  1065 ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
  1066 ** opcode causes the xFileControl method to write the current state of
  1067 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
  1068 ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
  1069 ** into an integer that the pArg argument points to. This capability
  1070 ** is used during testing and is only available when the SQLITE_TEST
  1071 ** compile-time option is used.
  1072 **
  1073 ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
  1074 ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
  1075 ** layer a hint of how large the database file will grow to be during the
  1076 ** current transaction.  This hint is not guaranteed to be accurate but it
  1077 ** is often close.  The underlying VFS might choose to preallocate database
  1078 ** file space based on this hint in order to help writes to the database
  1079 ** file run faster.
  1080 **
  1081 ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
  1082 ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
  1083 ** extends and truncates the database file in chunks of a size specified
  1084 ** by the user. The fourth argument to [sqlite3_file_control()] should 
  1085 ** point to an integer (type int) containing the new chunk-size to use
  1086 ** for the nominated database. Allocating database file space in large
  1087 ** chunks (say 1MB at a time), may reduce file-system fragmentation and
  1088 ** improve performance on some systems.
  1089 **
  1090 ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
  1091 ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
  1092 ** to the [sqlite3_file] object associated with a particular database
  1093 ** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
  1094 **
  1095 ** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
  1096 ** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
  1097 ** to the [sqlite3_file] object associated with the journal file (either
  1098 ** the [rollback journal] or the [write-ahead log]) for a particular database
  1099 ** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
  1100 **
  1101 ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
  1102 ** No longer in use.
  1103 **
  1104 ** <li>[[SQLITE_FCNTL_SYNC]]
  1105 ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
  1106 ** sent to the VFS immediately before the xSync method is invoked on a
  1107 ** database file descriptor. Or, if the xSync method is not invoked 
  1108 ** because the user has configured SQLite with 
  1109 ** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place 
  1110 ** of the xSync method. In most cases, the pointer argument passed with
  1111 ** this file-control is NULL. However, if the database file is being synced
  1112 ** as part of a multi-database commit, the argument points to a nul-terminated
  1113 ** string containing the transactions master-journal file name. VFSes that 
  1114 ** do not need this signal should silently ignore this opcode. Applications 
  1115 ** should not call [sqlite3_file_control()] with this opcode as doing so may 
  1116 ** disrupt the operation of the specialized VFSes that do require it.  
  1117 **
  1118 ** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]
  1119 ** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite
  1120 ** and sent to the VFS after a transaction has been committed immediately
  1121 ** but before the database is unlocked. VFSes that do not need this signal
  1122 ** should silently ignore this opcode. Applications should not call
  1123 ** [sqlite3_file_control()] with this opcode as doing so may disrupt the 
  1124 ** operation of the specialized VFSes that do require it.  
  1125 **
  1126 ** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
  1127 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
  1128 ** retry counts and intervals for certain disk I/O operations for the
  1129 ** windows [VFS] in order to provide robustness in the presence of
  1130 ** anti-virus programs.  By default, the windows VFS will retry file read,
  1131 ** file write, and file delete operations up to 10 times, with a delay
  1132 ** of 25 milliseconds before the first retry and with the delay increasing
  1133 ** by an additional 25 milliseconds with each subsequent retry.  This
  1134 ** opcode allows these two values (10 retries and 25 milliseconds of delay)
  1135 ** to be adjusted.  The values are changed for all database connections
  1136 ** within the same process.  The argument is a pointer to an array of two
  1137 ** integers where the first integer is the new retry count and the second
  1138 ** integer is the delay.  If either integer is negative, then the setting
  1139 ** is not changed but instead the prior value of that setting is written
  1140 ** into the array entry, allowing the current retry settings to be
  1141 ** interrogated.  The zDbName parameter is ignored.
  1142 **
  1143 ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
  1144 ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
  1145 ** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary
  1146 ** write ahead log and shared memory files used for transaction control
  1147 ** are automatically deleted when the latest connection to the database
  1148 ** closes.  Setting persistent WAL mode causes those files to persist after
  1149 ** close.  Persisting the files is useful when other processes that do not
  1150 ** have write permission on the directory containing the database file want
  1151 ** to read the database file, as the WAL and shared memory files must exist
  1152 ** in order for the database to be readable.  The fourth parameter to
  1153 ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
  1154 ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
  1155 ** WAL mode.  If the integer is -1, then it is overwritten with the current
  1156 ** WAL persistence setting.
  1157 **
  1158 ** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
  1159 ** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
  1160 ** persistent "powersafe-overwrite" or "PSOW" setting.  The PSOW setting
  1161 ** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
  1162 ** xDeviceCharacteristics methods. The fourth parameter to
  1163 ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
  1164 ** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
  1165 ** mode.  If the integer is -1, then it is overwritten with the current
  1166 ** zero-damage mode setting.
  1167 **
  1168 ** <li>[[SQLITE_FCNTL_OVERWRITE]]
  1169 ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
  1170 ** a write transaction to indicate that, unless it is rolled back for some
  1171 ** reason, the entire database file will be overwritten by the current 
  1172 ** transaction. This is used by VACUUM operations.
  1173 **
  1174 ** <li>[[SQLITE_FCNTL_VFSNAME]]
  1175 ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
  1176 ** all [VFSes] in the VFS stack.  The names are of all VFS shims and the
  1177 ** final bottom-level VFS are written into memory obtained from 
  1178 ** [sqlite3_malloc()] and the result is stored in the char* variable
  1179 ** that the fourth parameter of [sqlite3_file_control()] points to.
  1180 ** The caller is responsible for freeing the memory when done.  As with
  1181 ** all file-control actions, there is no guarantee that this will actually
  1182 ** do anything.  Callers should initialize the char* variable to a NULL
  1183 ** pointer in case this file-control is not implemented.  This file-control
  1184 ** is intended for diagnostic use only.
  1185 **
  1186 ** <li>[[SQLITE_FCNTL_VFS_POINTER]]
  1187 ** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
  1188 ** [VFSes] currently in use.  ^(The argument X in
  1189 ** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
  1190 ** of type "[sqlite3_vfs] **".  This opcodes will set *X
  1191 ** to a pointer to the top-level VFS.)^
  1192 ** ^When there are multiple VFS shims in the stack, this opcode finds the
  1193 ** upper-most shim only.
  1194 **
  1195 ** <li>[[SQLITE_FCNTL_PRAGMA]]
  1196 ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
  1197 ** file control is sent to the open [sqlite3_file] object corresponding
  1198 ** to the database file to which the pragma statement refers. ^The argument
  1199 ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
  1200 ** pointers to strings (char**) in which the second element of the array
  1201 ** is the name of the pragma and the third element is the argument to the
  1202 ** pragma or NULL if the pragma has no argument.  ^The handler for an
  1203 ** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
  1204 ** of the char** argument point to a string obtained from [sqlite3_mprintf()]
  1205 ** or the equivalent and that string will become the result of the pragma or
  1206 ** the error message if the pragma fails. ^If the
  1207 ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 
  1208 ** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
  1209 ** file control returns [SQLITE_OK], then the parser assumes that the
  1210 ** VFS has handled the PRAGMA itself and the parser generates a no-op
  1211 ** prepared statement if result string is NULL, or that returns a copy
  1212 ** of the result string if the string is non-NULL.
  1213 ** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
  1214 ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
  1215 ** that the VFS encountered an error while handling the [PRAGMA] and the
  1216 ** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
  1217 ** file control occurs at the beginning of pragma statement analysis and so
  1218 ** it is able to override built-in [PRAGMA] statements.
  1219 **
  1220 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
  1221 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
  1222 ** file-control may be invoked by SQLite on the database file handle
  1223 ** shortly after it is opened in order to provide a custom VFS with access
  1224 ** to the connections busy-handler callback. The argument is of type (void **)
  1225 ** - an array of two (void *) values. The first (void *) actually points
  1226 ** to a function of type (int (*)(void *)). In order to invoke the connections
  1227 ** busy-handler, this function should be invoked with the second (void *) in
  1228 ** the array as the only argument. If it returns non-zero, then the operation
  1229 ** should be retried. If it returns zero, the custom VFS should abandon the
  1230 ** current operation.
  1231 **
  1232 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
  1233 ** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
  1234 ** to have SQLite generate a
  1235 ** temporary filename using the same algorithm that is followed to generate
  1236 ** temporary filenames for TEMP tables and other internal uses.  The
  1237 ** argument should be a char** which will be filled with the filename
  1238 ** written into memory obtained from [sqlite3_malloc()].  The caller should
  1239 ** invoke [sqlite3_free()] on the result to avoid a memory leak.
  1240 **
  1241 ** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
  1242 ** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the
  1243 ** maximum number of bytes that will be used for memory-mapped I/O.
  1244 ** The argument is a pointer to a value of type sqlite3_int64 that
  1245 ** is an advisory maximum number of bytes in the file to memory map.  The
  1246 ** pointer is overwritten with the old value.  The limit is not changed if
  1247 ** the value originally pointed to is negative, and so the current limit 
  1248 ** can be queried by passing in a pointer to a negative number.  This
  1249 ** file-control is used internally to implement [PRAGMA mmap_size].
  1250 **
  1251 ** <li>[[SQLITE_FCNTL_TRACE]]
  1252 ** The [SQLITE_FCNTL_TRACE] file control provides advisory information
  1253 ** to the VFS about what the higher layers of the SQLite stack are doing.
  1254 ** This file control is used by some VFS activity tracing [shims].
  1255 ** The argument is a zero-terminated string.  Higher layers in the
  1256 ** SQLite stack may generate instances of this file control if
  1257 ** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
  1258 **
  1259 ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
  1260 ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
  1261 ** pointer to an integer and it writes a boolean into that integer depending
  1262 ** on whether or not the file has been renamed, moved, or deleted since it
  1263 ** was first opened.
  1264 **
  1265 ** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
  1266 ** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
  1267 ** underlying native file handle associated with a file handle.  This file
  1268 ** control interprets its argument as a pointer to a native file handle and
  1269 ** writes the resulting value there.
  1270 **
  1271 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
  1272 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This
  1273 ** opcode causes the xFileControl method to swap the file handle with the one
  1274 ** pointed to by the pArg argument.  This capability is used during testing
  1275 ** and only needs to be supported when SQLITE_TEST is defined.
  1276 **
  1277 ** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
  1278 ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
  1279 ** be advantageous to block on the next WAL lock if the lock is not immediately
  1280 ** available.  The WAL subsystem issues this signal during rare
  1281 ** circumstances in order to fix a problem with priority inversion.
  1282 ** Applications should <em>not</em> use this file-control.
  1283 **
  1284 ** <li>[[SQLITE_FCNTL_ZIPVFS]]
  1285 ** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
  1286 ** VFS should return SQLITE_NOTFOUND for this opcode.
  1287 **
  1288 ** <li>[[SQLITE_FCNTL_RBU]]
  1289 ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
  1290 ** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for
  1291 ** this opcode.  
  1292 ** </ul>
  1293 */
  1294 #define SQLITE_FCNTL_LOCKSTATE               1
  1295 #define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
  1296 #define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
  1297 #define SQLITE_FCNTL_LAST_ERRNO              4
  1298 #define SQLITE_FCNTL_SIZE_HINT               5
  1299 #define SQLITE_FCNTL_CHUNK_SIZE              6
  1300 #define SQLITE_FCNTL_FILE_POINTER            7
  1301 #define SQLITE_FCNTL_SYNC_OMITTED            8
  1302 #define SQLITE_FCNTL_WIN32_AV_RETRY          9
  1303 #define SQLITE_FCNTL_PERSIST_WAL            10
  1304 #define SQLITE_FCNTL_OVERWRITE              11
  1305 #define SQLITE_FCNTL_VFSNAME                12
  1306 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13
  1307 #define SQLITE_FCNTL_PRAGMA                 14
  1308 #define SQLITE_FCNTL_BUSYHANDLER            15
  1309 #define SQLITE_FCNTL_TEMPFILENAME           16
  1310 #define SQLITE_FCNTL_MMAP_SIZE              18
  1311 #define SQLITE_FCNTL_TRACE                  19
  1312 #define SQLITE_FCNTL_HAS_MOVED              20
  1313 #define SQLITE_FCNTL_SYNC                   21
  1314 #define SQLITE_FCNTL_COMMIT_PHASETWO        22
  1315 #define SQLITE_FCNTL_WIN32_SET_HANDLE       23
  1316 #define SQLITE_FCNTL_WAL_BLOCK              24
  1317 #define SQLITE_FCNTL_ZIPVFS                 25
  1318 #define SQLITE_FCNTL_RBU                    26
  1319 #define SQLITE_FCNTL_VFS_POINTER            27
  1320 #define SQLITE_FCNTL_JOURNAL_POINTER        28
  1321 #define SQLITE_FCNTL_WIN32_GET_HANDLE       29
  1322 #define SQLITE_FCNTL_PDB                    30
  1323 
  1324 /* deprecated names */
  1325 #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
  1326 #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
  1327 #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
  1328 
  1329 
  1330 /*
  1331 ** CAPI3REF: Mutex Handle
  1332 **
  1333 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
  1334 ** abstract type for a mutex object.  The SQLite core never looks
  1335 ** at the internal representation of an [sqlite3_mutex].  It only
  1336 ** deals with pointers to the [sqlite3_mutex] object.
  1337 **
  1338 ** Mutexes are created using [sqlite3_mutex_alloc()].
  1339 */
  1340 typedef struct sqlite3_mutex sqlite3_mutex;
  1341 
  1342 /*
  1343 ** CAPI3REF: Loadable Extension Thunk
  1344 **
  1345 ** A pointer to the opaque sqlite3_api_routines structure is passed as
  1346 ** the third parameter to entry points of [loadable extensions].  This
  1347 ** structure must be typedefed in order to work around compiler warnings
  1348 ** on some platforms.
  1349 */
  1350 typedef struct sqlite3_api_routines sqlite3_api_routines;
  1351 
  1352 /*
  1353 ** CAPI3REF: OS Interface Object
  1354 **
  1355 ** An instance of the sqlite3_vfs object defines the interface between
  1356 ** the SQLite core and the underlying operating system.  The "vfs"
  1357 ** in the name of the object stands for "virtual file system".  See
  1358 ** the [VFS | VFS documentation] for further information.
  1359 **
  1360 ** The value of the iVersion field is initially 1 but may be larger in
  1361 ** future versions of SQLite.  Additional fields may be appended to this
  1362 ** object when the iVersion value is increased.  Note that the structure
  1363 ** of the sqlite3_vfs object changes in the transaction between
  1364 ** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not
  1365 ** modified.
  1366 **
  1367 ** The szOsFile field is the size of the subclassed [sqlite3_file]
  1368 ** structure used by this VFS.  mxPathname is the maximum length of
  1369 ** a pathname in this VFS.
  1370 **
  1371 ** Registered sqlite3_vfs objects are kept on a linked list formed by
  1372 ** the pNext pointer.  The [sqlite3_vfs_register()]
  1373 ** and [sqlite3_vfs_unregister()] interfaces manage this list
  1374 ** in a thread-safe way.  The [sqlite3_vfs_find()] interface
  1375 ** searches the list.  Neither the application code nor the VFS
  1376 ** implementation should use the pNext pointer.
  1377 **
  1378 ** The pNext field is the only field in the sqlite3_vfs
  1379 ** structure that SQLite will ever modify.  SQLite will only access
  1380 ** or modify this field while holding a particular static mutex.
  1381 ** The application should never modify anything within the sqlite3_vfs
  1382 ** object once the object has been registered.
  1383 **
  1384 ** The zName field holds the name of the VFS module.  The name must
  1385 ** be unique across all VFS modules.
  1386 **
  1387 ** [[sqlite3_vfs.xOpen]]
  1388 ** ^SQLite guarantees that the zFilename parameter to xOpen
  1389 ** is either a NULL pointer or string obtained
  1390 ** from xFullPathname() with an optional suffix added.
  1391 ** ^If a suffix is added to the zFilename parameter, it will
  1392 ** consist of a single "-" character followed by no more than
  1393 ** 11 alphanumeric and/or "-" characters.
  1394 ** ^SQLite further guarantees that
  1395 ** the string will be valid and unchanged until xClose() is
  1396 ** called. Because of the previous sentence,
  1397 ** the [sqlite3_file] can safely store a pointer to the
  1398 ** filename if it needs to remember the filename for some reason.
  1399 ** If the zFilename parameter to xOpen is a NULL pointer then xOpen
  1400 ** must invent its own temporary name for the file.  ^Whenever the 
  1401 ** xFilename parameter is NULL it will also be the case that the
  1402 ** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
  1403 **
  1404 ** The flags argument to xOpen() includes all bits set in
  1405 ** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]
  1406 ** or [sqlite3_open16()] is used, then flags includes at least
  1407 ** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. 
  1408 ** If xOpen() opens a file read-only then it sets *pOutFlags to
  1409 ** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
  1410 **
  1411 ** ^(SQLite will also add one of the following flags to the xOpen()
  1412 ** call, depending on the object being opened:
  1413 **
  1414 ** <ul>
  1415 ** <li>  [SQLITE_OPEN_MAIN_DB]
  1416 ** <li>  [SQLITE_OPEN_MAIN_JOURNAL]
  1417 ** <li>  [SQLITE_OPEN_TEMP_DB]
  1418 ** <li>  [SQLITE_OPEN_TEMP_JOURNAL]
  1419 ** <li>  [SQLITE_OPEN_TRANSIENT_DB]
  1420 ** <li>  [SQLITE_OPEN_SUBJOURNAL]
  1421 ** <li>  [SQLITE_OPEN_MASTER_JOURNAL]
  1422 ** <li>  [SQLITE_OPEN_WAL]
  1423 ** </ul>)^
  1424 **
  1425 ** The file I/O implementation can use the object type flags to
  1426 ** change the way it deals with files.  For example, an application
  1427 ** that does not care about crash recovery or rollback might make
  1428 ** the open of a journal file a no-op.  Writes to this journal would
  1429 ** also be no-ops, and any attempt to read the journal would return
  1430 ** SQLITE_IOERR.  Or the implementation might recognize that a database
  1431 ** file will be doing page-aligned sector reads and writes in a random
  1432 ** order and set up its I/O subsystem accordingly.
  1433 **
  1434 ** SQLite might also add one of the following flags to the xOpen method:
  1435 **
  1436 ** <ul>
  1437 ** <li> [SQLITE_OPEN_DELETEONCLOSE]
  1438 ** <li> [SQLITE_OPEN_EXCLUSIVE]
  1439 ** </ul>
  1440 **
  1441 ** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
  1442 ** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
  1443 ** will be set for TEMP databases and their journals, transient
  1444 ** databases, and subjournals.
  1445 **
  1446 ** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
  1447 ** with the [SQLITE_OPEN_CREATE] flag, which are both directly
  1448 ** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
  1449 ** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 
  1450 ** SQLITE_OPEN_CREATE, is used to indicate that file should always
  1451 ** be created, and that it is an error if it already exists.
  1452 ** It is <i>not</i> used to indicate the file should be opened 
  1453 ** for exclusive access.
  1454 **
  1455 ** ^At least szOsFile bytes of memory are allocated by SQLite
  1456 ** to hold the  [sqlite3_file] structure passed as the third
  1457 ** argument to xOpen.  The xOpen method does not have to
  1458 ** allocate the structure; it should just fill it in.  Note that
  1459 ** the xOpen method must set the sqlite3_file.pMethods to either
  1460 ** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do
  1461 ** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods
  1462 ** element will be valid after xOpen returns regardless of the success
  1463 ** or failure of the xOpen call.
  1464 **
  1465 ** [[sqlite3_vfs.xAccess]]
  1466 ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
  1467 ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
  1468 ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
  1469 ** to test whether a file is at least readable.   The file can be a
  1470 ** directory.
  1471 **
  1472 ** ^SQLite will always allocate at least mxPathname+1 bytes for the
  1473 ** output buffer xFullPathname.  The exact size of the output buffer
  1474 ** is also passed as a parameter to both  methods. If the output buffer
  1475 ** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
  1476 ** handled as a fatal error by SQLite, vfs implementations should endeavor
  1477 ** to prevent this by setting mxPathname to a sufficiently large value.
  1478 **
  1479 ** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
  1480 ** interfaces are not strictly a part of the filesystem, but they are
  1481 ** included in the VFS structure for completeness.
  1482 ** The xRandomness() function attempts to return nBytes bytes
  1483 ** of good-quality randomness into zOut.  The return value is
  1484 ** the actual number of bytes of randomness obtained.
  1485 ** The xSleep() method causes the calling thread to sleep for at
  1486 ** least the number of microseconds given.  ^The xCurrentTime()
  1487 ** method returns a Julian Day Number for the current date and time as
  1488 ** a floating point value.
  1489 ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
  1490 ** Day Number multiplied by 86400000 (the number of milliseconds in 
  1491 ** a 24-hour day).  
  1492 ** ^SQLite will use the xCurrentTimeInt64() method to get the current
  1493 ** date and time if that method is available (if iVersion is 2 or 
  1494 ** greater and the function pointer is not NULL) and will fall back
  1495 ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
  1496 **
  1497 ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
  1498 ** are not used by the SQLite core.  These optional interfaces are provided
  1499 ** by some VFSes to facilitate testing of the VFS code. By overriding 
  1500 ** system calls with functions under its control, a test program can
  1501 ** simulate faults and error conditions that would otherwise be difficult
  1502 ** or impossible to induce.  The set of system calls that can be overridden
  1503 ** varies from one VFS to another, and from one version of the same VFS to the
  1504 ** next.  Applications that use these interfaces must be prepared for any
  1505 ** or all of these interfaces to be NULL or for their behavior to change
  1506 ** from one release to the next.  Applications must not attempt to access
  1507 ** any of these methods if the iVersion of the VFS is less than 3.
  1508 */
  1509 typedef struct sqlite3_vfs sqlite3_vfs;
  1510 typedef void (*sqlite3_syscall_ptr)(void);
  1511 struct sqlite3_vfs {
  1512   int iVersion;            /* Structure version number (currently 3) */
  1513   int szOsFile;            /* Size of subclassed sqlite3_file */
  1514   int mxPathname;          /* Maximum file pathname length */
  1515   sqlite3_vfs *pNext;      /* Next registered VFS */
  1516   const char *zName;       /* Name of this virtual file system */
  1517   void *pAppData;          /* Pointer to application-specific data */
  1518   int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
  1519                int flags, int *pOutFlags);
  1520   int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
  1521   int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
  1522   int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
  1523   void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
  1524   void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
  1525   void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
  1526   void (*xDlClose)(sqlite3_vfs*, void*);
  1527   int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
  1528   int (*xSleep)(sqlite3_vfs*, int microseconds);
  1529   int (*xCurrentTime)(sqlite3_vfs*, double*);
  1530   int (*xGetLastError)(sqlite3_vfs*, int, char *);
  1531   /*
  1532   ** The methods above are in version 1 of the sqlite_vfs object
  1533   ** definition.  Those that follow are added in version 2 or later
  1534   */
  1535   int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
  1536   /*
  1537   ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
  1538   ** Those below are for version 3 and greater.
  1539   */
  1540   int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
  1541   sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
  1542   const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
  1543   /*
  1544   ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
  1545   ** New fields may be appended in future versions.  The iVersion
  1546   ** value will increment whenever this happens. 
  1547   */
  1548 };
  1549 
  1550 /*
  1551 ** CAPI3REF: Flags for the xAccess VFS method
  1552 **
  1553 ** These integer constants can be used as the third parameter to
  1554 ** the xAccess method of an [sqlite3_vfs] object.  They determine
  1555 ** what kind of permissions the xAccess method is looking for.
  1556 ** With SQLITE_ACCESS_EXISTS, the xAccess method
  1557 ** simply checks whether the file exists.
  1558 ** With SQLITE_ACCESS_READWRITE, the xAccess method
  1559 ** checks whether the named directory is both readable and writable
  1560 ** (in other words, if files can be added, removed, and renamed within
  1561 ** the directory).
  1562 ** The SQLITE_ACCESS_READWRITE constant is currently used only by the
  1563 ** [temp_store_directory pragma], though this could change in a future
  1564 ** release of SQLite.
  1565 ** With SQLITE_ACCESS_READ, the xAccess method
  1566 ** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is
  1567 ** currently unused, though it might be used in a future release of
  1568 ** SQLite.
  1569 */
  1570 #define SQLITE_ACCESS_EXISTS    0
  1571 #define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */
  1572 #define SQLITE_ACCESS_READ      2   /* Unused */
  1573 
  1574 /*
  1575 ** CAPI3REF: Flags for the xShmLock VFS method
  1576 **
  1577 ** These integer constants define the various locking operations
  1578 ** allowed by the xShmLock method of [sqlite3_io_methods].  The
  1579 ** following are the only legal combinations of flags to the
  1580 ** xShmLock method:
  1581 **
  1582 ** <ul>
  1583 ** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
  1584 ** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
  1585 ** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
  1586 ** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
  1587 ** </ul>
  1588 **
  1589 ** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
  1590 ** was given on the corresponding lock.  
  1591 **
  1592 ** The xShmLock method can transition between unlocked and SHARED or
  1593 ** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
  1594 ** and EXCLUSIVE.
  1595 */
  1596 #define SQLITE_SHM_UNLOCK       1
  1597 #define SQLITE_SHM_LOCK         2
  1598 #define SQLITE_SHM_SHARED       4
  1599 #define SQLITE_SHM_EXCLUSIVE    8
  1600 
  1601 /*
  1602 ** CAPI3REF: Maximum xShmLock index
  1603 **
  1604 ** The xShmLock method on [sqlite3_io_methods] may use values
  1605 ** between 0 and this upper bound as its "offset" argument.
  1606 ** The SQLite core will never attempt to acquire or release a
  1607 ** lock outside of this range
  1608 */
  1609 #define SQLITE_SHM_NLOCK        8
  1610 
  1611 
  1612 /*
  1613 ** CAPI3REF: Initialize The SQLite Library
  1614 **
  1615 ** ^The sqlite3_initialize() routine initializes the
  1616 ** SQLite library.  ^The sqlite3_shutdown() routine
  1617 ** deallocates any resources that were allocated by sqlite3_initialize().
  1618 ** These routines are designed to aid in process initialization and
  1619 ** shutdown on embedded systems.  Workstation applications using
  1620 ** SQLite normally do not need to invoke either of these routines.
  1621 **
  1622 ** A call to sqlite3_initialize() is an "effective" call if it is
  1623 ** the first time sqlite3_initialize() is invoked during the lifetime of
  1624 ** the process, or if it is the first time sqlite3_initialize() is invoked
  1625 ** following a call to sqlite3_shutdown().  ^(Only an effective call
  1626 ** of sqlite3_initialize() does any initialization.  All other calls
  1627 ** are harmless no-ops.)^
  1628 **
  1629 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
  1630 ** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only
  1631 ** an effective call to sqlite3_shutdown() does any deinitialization.
  1632 ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
  1633 **
  1634 ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
  1635 ** is not.  The sqlite3_shutdown() interface must only be called from a
  1636 ** single thread.  All open [database connections] must be closed and all
  1637 ** other SQLite resources must be deallocated prior to invoking
  1638 ** sqlite3_shutdown().
  1639 **
  1640 ** Among other things, ^sqlite3_initialize() will invoke
  1641 ** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()
  1642 ** will invoke sqlite3_os_end().
  1643 **
  1644 ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
  1645 ** ^If for some reason, sqlite3_initialize() is unable to initialize
  1646 ** the library (perhaps it is unable to allocate a needed resource such
  1647 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
  1648 **
  1649 ** ^The sqlite3_initialize() routine is called internally by many other
  1650 ** SQLite interfaces so that an application usually does not need to
  1651 ** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]
  1652 ** calls sqlite3_initialize() so the SQLite library will be automatically
  1653 ** initialized when [sqlite3_open()] is called if it has not be initialized
  1654 ** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
  1655 ** compile-time option, then the automatic calls to sqlite3_initialize()
  1656 ** are omitted and the application must call sqlite3_initialize() directly
  1657 ** prior to using any other SQLite interface.  For maximum portability,
  1658 ** it is recommended that applications always invoke sqlite3_initialize()
  1659 ** directly prior to using any other SQLite interface.  Future releases
  1660 ** of SQLite may require this.  In other words, the behavior exhibited
  1661 ** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the
  1662 ** default behavior in some future release of SQLite.
  1663 **
  1664 ** The sqlite3_os_init() routine does operating-system specific
  1665 ** initialization of the SQLite library.  The sqlite3_os_end()
  1666 ** routine undoes the effect of sqlite3_os_init().  Typical tasks
  1667 ** performed by these routines include allocation or deallocation
  1668 ** of static resources, initialization of global variables,
  1669 ** setting up a default [sqlite3_vfs] module, or setting up
  1670 ** a default configuration using [sqlite3_config()].
  1671 **
  1672 ** The application should never invoke either sqlite3_os_init()
  1673 ** or sqlite3_os_end() directly.  The application should only invoke
  1674 ** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()
  1675 ** interface is called automatically by sqlite3_initialize() and
  1676 ** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate
  1677 ** implementations for sqlite3_os_init() and sqlite3_os_end()
  1678 ** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
  1679 ** When [custom builds | built for other platforms]
  1680 ** (using the [SQLITE_OS_OTHER=1] compile-time
  1681 ** option) the application must supply a suitable implementation for
  1682 ** sqlite3_os_init() and sqlite3_os_end().  An application-supplied
  1683 ** implementation of sqlite3_os_init() or sqlite3_os_end()
  1684 ** must return [SQLITE_OK] on success and some other [error code] upon
  1685 ** failure.
  1686 */
  1687 SQLITE_API int sqlite3_initialize(void);
  1688 SQLITE_API int sqlite3_shutdown(void);
  1689 SQLITE_API int sqlite3_os_init(void);
  1690 SQLITE_API int sqlite3_os_end(void);
  1691 
  1692 /*
  1693 ** CAPI3REF: Configuring The SQLite Library
  1694 **
  1695 ** The sqlite3_config() interface is used to make global configuration
  1696 ** changes to SQLite in order to tune SQLite to the specific needs of
  1697 ** the application.  The default configuration is recommended for most
  1698 ** applications and so this routine is usually not necessary.  It is
  1699 ** provided to support rare applications with unusual needs.
  1700 **
  1701 ** <b>The sqlite3_config() interface is not threadsafe. The application
  1702 ** must ensure that no other SQLite interfaces are invoked by other
  1703 ** threads while sqlite3_config() is running.</b>
  1704 **
  1705 ** The sqlite3_config() interface
  1706 ** may only be invoked prior to library initialization using
  1707 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
  1708 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
  1709 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
  1710 ** Note, however, that ^sqlite3_config() can be called as part of the
  1711 ** implementation of an application-defined [sqlite3_os_init()].
  1712 **
  1713 ** The first argument to sqlite3_config() is an integer
  1714 ** [configuration option] that determines
  1715 ** what property of SQLite is to be configured.  Subsequent arguments
  1716 ** vary depending on the [configuration option]
  1717 ** in the first argument.
  1718 **
  1719 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
  1720 ** ^If the option is unknown or SQLite is unable to set the option
  1721 ** then this routine returns a non-zero [error code].
  1722 */
  1723 SQLITE_API int sqlite3_config(int, ...);
  1724 
  1725 /*
  1726 ** CAPI3REF: Configure database connections
  1727 ** METHOD: sqlite3
  1728 **
  1729 ** The sqlite3_db_config() interface is used to make configuration
  1730 ** changes to a [database connection].  The interface is similar to
  1731 ** [sqlite3_config()] except that the changes apply to a single
  1732 ** [database connection] (specified in the first argument).
  1733 **
  1734 ** The second argument to sqlite3_db_config(D,V,...)  is the
  1735 ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code 
  1736 ** that indicates what aspect of the [database connection] is being configured.
  1737 ** Subsequent arguments vary depending on the configuration verb.
  1738 **
  1739 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
  1740 ** the call is considered successful.
  1741 */
  1742 SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
  1743 
  1744 /*
  1745 ** CAPI3REF: Memory Allocation Routines
  1746 **
  1747 ** An instance of this object defines the interface between SQLite
  1748 ** and low-level memory allocation routines.
  1749 **
  1750 ** This object is used in only one place in the SQLite interface.
  1751 ** A pointer to an instance of this object is the argument to
  1752 ** [sqlite3_config()] when the configuration option is
  1753 ** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  
  1754 ** By creating an instance of this object
  1755 ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
  1756 ** during configuration, an application can specify an alternative
  1757 ** memory allocation subsystem for SQLite to use for all of its
  1758 ** dynamic memory needs.
  1759 **
  1760 ** Note that SQLite comes with several [built-in memory allocators]
  1761 ** that are perfectly adequate for the overwhelming majority of applications
  1762 ** and that this object is only useful to a tiny minority of applications
  1763 ** with specialized memory allocation requirements.  This object is
  1764 ** also used during testing of SQLite in order to specify an alternative
  1765 ** memory allocator that simulates memory out-of-memory conditions in
  1766 ** order to verify that SQLite recovers gracefully from such
  1767 ** conditions.
  1768 **
  1769 ** The xMalloc, xRealloc, and xFree methods must work like the
  1770 ** malloc(), realloc() and free() functions from the standard C library.
  1771 ** ^SQLite guarantees that the second argument to
  1772 ** xRealloc is always a value returned by a prior call to xRoundup.
  1773 **
  1774 ** xSize should return the allocated size of a memory allocation
  1775 ** previously obtained from xMalloc or xRealloc.  The allocated size
  1776 ** is always at least as big as the requested size but may be larger.
  1777 **
  1778 ** The xRoundup method returns what would be the allocated size of
  1779 ** a memory allocation given a particular requested size.  Most memory
  1780 ** allocators round up memory allocations at least to the next multiple
  1781 ** of 8.  Some allocators round up to a larger multiple or to a power of 2.
  1782 ** Every memory allocation request coming in through [sqlite3_malloc()]
  1783 ** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, 
  1784 ** that causes the corresponding memory allocation to fail.
  1785 **
  1786 ** The xInit method initializes the memory allocator.  For example,
  1787 ** it might allocate any require mutexes or initialize internal data
  1788 ** structures.  The xShutdown method is invoked (indirectly) by
  1789 ** [sqlite3_shutdown()] and should deallocate any resources acquired
  1790 ** by xInit.  The pAppData pointer is used as the only parameter to
  1791 ** xInit and xShutdown.
  1792 **
  1793 ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
  1794 ** the xInit method, so the xInit method need not be threadsafe.  The
  1795 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
  1796 ** not need to be threadsafe either.  For all other methods, SQLite
  1797 ** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
  1798 ** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
  1799 ** it is by default) and so the methods are automatically serialized.
  1800 ** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
  1801 ** methods must be threadsafe or else make their own arrangements for
  1802 ** serialization.
  1803 **
  1804 ** SQLite will never invoke xInit() more than once without an intervening
  1805 ** call to xShutdown().
  1806 */
  1807 typedef struct sqlite3_mem_methods sqlite3_mem_methods;
  1808 struct sqlite3_mem_methods {
  1809   void *(*xMalloc)(int);         /* Memory allocation function */
  1810   void (*xFree)(void*);          /* Free a prior allocation */
  1811   void *(*xRealloc)(void*,int);  /* Resize an allocation */
  1812   int (*xSize)(void*);           /* Return the size of an allocation */
  1813   int (*xRoundup)(int);          /* Round up request size to allocation size */
  1814   int (*xInit)(void*);           /* Initialize the memory allocator */
  1815   void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
  1816   void *pAppData;                /* Argument to xInit() and xShutdown() */
  1817 };
  1818 
  1819 /*
  1820 ** CAPI3REF: Configuration Options
  1821 ** KEYWORDS: {configuration option}
  1822 **
  1823 ** These constants are the available integer configuration options that
  1824 ** can be passed as the first argument to the [sqlite3_config()] interface.
  1825 **
  1826 ** New configuration options may be added in future releases of SQLite.
  1827 ** Existing configuration options might be discontinued.  Applications
  1828 ** should check the return code from [sqlite3_config()] to make sure that
  1829 ** the call worked.  The [sqlite3_config()] interface will return a
  1830 ** non-zero [error code] if a discontinued or unsupported configuration option
  1831 ** is invoked.
  1832 **
  1833 ** <dl>
  1834 ** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
  1835 ** <dd>There are no arguments to this option.  ^This option sets the
  1836 ** [threading mode] to Single-thread.  In other words, it disables
  1837 ** all mutexing and puts SQLite into a mode where it can only be used
  1838 ** by a single thread.   ^If SQLite is compiled with
  1839 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1840 ** it is not possible to change the [threading mode] from its default
  1841 ** value of Single-thread and so [sqlite3_config()] will return 
  1842 ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
  1843 ** configuration option.</dd>
  1844 **
  1845 ** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>
  1846 ** <dd>There are no arguments to this option.  ^This option sets the
  1847 ** [threading mode] to Multi-thread.  In other words, it disables
  1848 ** mutexing on [database connection] and [prepared statement] objects.
  1849 ** The application is responsible for serializing access to
  1850 ** [database connections] and [prepared statements].  But other mutexes
  1851 ** are enabled so that SQLite will be safe to use in a multi-threaded
  1852 ** environment as long as no two threads attempt to use the same
  1853 ** [database connection] at the same time.  ^If SQLite is compiled with
  1854 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1855 ** it is not possible to set the Multi-thread [threading mode] and
  1856 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  1857 ** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
  1858 **
  1859 ** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>
  1860 ** <dd>There are no arguments to this option.  ^This option sets the
  1861 ** [threading mode] to Serialized. In other words, this option enables
  1862 ** all mutexes including the recursive
  1863 ** mutexes on [database connection] and [prepared statement] objects.
  1864 ** In this mode (which is the default when SQLite is compiled with
  1865 ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
  1866 ** to [database connections] and [prepared statements] so that the
  1867 ** application is free to use the same [database connection] or the
  1868 ** same [prepared statement] in different threads at the same time.
  1869 ** ^If SQLite is compiled with
  1870 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1871 ** it is not possible to set the Serialized [threading mode] and
  1872 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
  1873 ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
  1874 **
  1875 ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
  1876 ** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is 
  1877 ** a pointer to an instance of the [sqlite3_mem_methods] structure.
  1878 ** The argument specifies
  1879 ** alternative low-level memory allocation routines to be used in place of
  1880 ** the memory allocation routines built into SQLite.)^ ^SQLite makes
  1881 ** its own private copy of the content of the [sqlite3_mem_methods] structure
  1882 ** before the [sqlite3_config()] call returns.</dd>
  1883 **
  1884 ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
  1885 ** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
  1886 ** is a pointer to an instance of the [sqlite3_mem_methods] structure.
  1887 ** The [sqlite3_mem_methods]
  1888 ** structure is filled with the currently defined memory allocation routines.)^
  1889 ** This option can be used to overload the default memory allocation
  1890 ** routines with a wrapper that simulations memory allocation failure or
  1891 ** tracks memory usage, for example. </dd>
  1892 **
  1893 ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
  1894 ** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
  1895 ** interpreted as a boolean, which enables or disables the collection of
  1896 ** memory allocation statistics. ^(When memory allocation statistics are
  1897 ** disabled, the following SQLite interfaces become non-operational:
  1898 **   <ul>
  1899 **   <li> [sqlite3_memory_used()]
  1900 **   <li> [sqlite3_memory_highwater()]
  1901 **   <li> [sqlite3_soft_heap_limit64()]
  1902 **   <li> [sqlite3_status64()]
  1903 **   </ul>)^
  1904 ** ^Memory allocation statistics are enabled by default unless SQLite is
  1905 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
  1906 ** allocation statistics are disabled by default.
  1907 ** </dd>
  1908 **
  1909 ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
  1910 ** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
  1911 ** that SQLite can use for scratch memory.  ^(There are three arguments
  1912 ** to SQLITE_CONFIG_SCRATCH:  A pointer an 8-byte
  1913 ** aligned memory buffer from which the scratch allocations will be
  1914 ** drawn, the size of each scratch allocation (sz),
  1915 ** and the maximum number of scratch allocations (N).)^
  1916 ** The first argument must be a pointer to an 8-byte aligned buffer
  1917 ** of at least sz*N bytes of memory.
  1918 ** ^SQLite will not use more than one scratch buffers per thread.
  1919 ** ^SQLite will never request a scratch buffer that is more than 6
  1920 ** times the database page size.
  1921 ** ^If SQLite needs needs additional
  1922 ** scratch memory beyond what is provided by this configuration option, then 
  1923 ** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
  1924 ** ^When the application provides any amount of scratch memory using
  1925 ** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
  1926 ** [sqlite3_malloc|heap allocations].
  1927 ** This can help [Robson proof|prevent memory allocation failures] due to heap
  1928 ** fragmentation in low-memory embedded systems.
  1929 ** </dd>
  1930 **
  1931 ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
  1932 ** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool
  1933 ** that SQLite can use for the database page cache with the default page
  1934 ** cache implementation.  
  1935 ** This configuration option is a no-op if an application-define page
  1936 ** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].
  1937 ** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
  1938 ** 8-byte aligned memory (pMem), the size of each page cache line (sz),
  1939 ** and the number of cache lines (N).
  1940 ** The sz argument should be the size of the largest database page
  1941 ** (a power of two between 512 and 65536) plus some extra bytes for each
  1942 ** page header.  ^The number of extra bytes needed by the page header
  1943 ** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].
  1944 ** ^It is harmless, apart from the wasted memory,
  1945 ** for the sz parameter to be larger than necessary.  The pMem
  1946 ** argument must be either a NULL pointer or a pointer to an 8-byte
  1947 ** aligned block of memory of at least sz*N bytes, otherwise
  1948 ** subsequent behavior is undefined.
  1949 ** ^When pMem is not NULL, SQLite will strive to use the memory provided
  1950 ** to satisfy page cache needs, falling back to [sqlite3_malloc()] if
  1951 ** a page cache line is larger than sz bytes or if all of the pMem buffer
  1952 ** is exhausted.
  1953 ** ^If pMem is NULL and N is non-zero, then each database connection
  1954 ** does an initial bulk allocation for page cache memory
  1955 ** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or
  1956 ** of -1024*N bytes if N is negative, . ^If additional
  1957 ** page cache memory is needed beyond what is provided by the initial
  1958 ** allocation, then SQLite goes to [sqlite3_malloc()] separately for each
  1959 ** additional cache line. </dd>
  1960 **
  1961 ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
  1962 ** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer 
  1963 ** that SQLite will use for all of its dynamic memory allocation needs
  1964 ** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
  1965 ** [SQLITE_CONFIG_PAGECACHE].
  1966 ** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
  1967 ** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
  1968 ** [SQLITE_ERROR] if invoked otherwise.
  1969 ** ^There are three arguments to SQLITE_CONFIG_HEAP:
  1970 ** An 8-byte aligned pointer to the memory,
  1971 ** the number of bytes in the memory buffer, and the minimum allocation size.
  1972 ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
  1973 ** to using its default memory allocator (the system malloc() implementation),
  1974 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the
  1975 ** memory pointer is not NULL then the alternative memory
  1976 ** allocator is engaged to handle all of SQLites memory allocation needs.
  1977 ** The first pointer (the memory pointer) must be aligned to an 8-byte
  1978 ** boundary or subsequent behavior of SQLite will be undefined.
  1979 ** The minimum allocation size is capped at 2**12. Reasonable values
  1980 ** for the minimum allocation size are 2**5 through 2**8.</dd>
  1981 **
  1982 ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
  1983 ** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
  1984 ** pointer to an instance of the [sqlite3_mutex_methods] structure.
  1985 ** The argument specifies alternative low-level mutex routines to be used
  1986 ** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of
  1987 ** the content of the [sqlite3_mutex_methods] structure before the call to
  1988 ** [sqlite3_config()] returns. ^If SQLite is compiled with
  1989 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  1990 ** the entire mutexing subsystem is omitted from the build and hence calls to
  1991 ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
  1992 ** return [SQLITE_ERROR].</dd>
  1993 **
  1994 ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
  1995 ** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
  1996 ** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The
  1997 ** [sqlite3_mutex_methods]
  1998 ** structure is filled with the currently defined mutex routines.)^
  1999 ** This option can be used to overload the default mutex allocation
  2000 ** routines with a wrapper used to track mutex usage for performance
  2001 ** profiling or testing, for example.   ^If SQLite is compiled with
  2002 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
  2003 ** the entire mutexing subsystem is omitted from the build and hence calls to
  2004 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
  2005 ** return [SQLITE_ERROR].</dd>
  2006 **
  2007 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
  2008 ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
  2009 ** the default size of lookaside memory on each [database connection].
  2010 ** The first argument is the
  2011 ** size of each lookaside buffer slot and the second is the number of
  2012 ** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE
  2013 ** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
  2014 ** option to [sqlite3_db_config()] can be used to change the lookaside
  2015 ** configuration on individual connections.)^ </dd>
  2016 **
  2017 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
  2018 ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is 
  2019 ** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies
  2020 ** the interface to a custom page cache implementation.)^
  2021 ** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
  2022 **
  2023 ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
  2024 ** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
  2025 ** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of
  2026 ** the current page cache implementation into that object.)^ </dd>
  2027 **
  2028 ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
  2029 ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
  2030 ** global [error log].
  2031 ** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
  2032 ** function with a call signature of void(*)(void*,int,const char*), 
  2033 ** and a pointer to void. ^If the function pointer is not NULL, it is
  2034 ** invoked by [sqlite3_log()] to process each logging event.  ^If the
  2035 ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
  2036 ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
  2037 ** passed through as the first parameter to the application-defined logger
  2038 ** function whenever that function is invoked.  ^The second parameter to
  2039 ** the logger function is a copy of the first parameter to the corresponding
  2040 ** [sqlite3_log()] call and is intended to be a [result code] or an
  2041 ** [extended result code].  ^The third parameter passed to the logger is
  2042 ** log message after formatting via [sqlite3_snprintf()].
  2043 ** The SQLite logging interface is not reentrant; the logger function
  2044 ** supplied by the application must not invoke any SQLite interface.
  2045 ** In a multi-threaded application, the application-defined logger
  2046 ** function must be threadsafe. </dd>
  2047 **
  2048 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
  2049 ** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
  2050 ** If non-zero, then URI handling is globally enabled. If the parameter is zero,
  2051 ** then URI handling is globally disabled.)^ ^If URI handling is globally
  2052 ** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
  2053 ** [sqlite3_open16()] or
  2054 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
  2055 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
  2056 ** connection is opened. ^If it is globally disabled, filenames are
  2057 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
  2058 ** database connection is opened. ^(By default, URI handling is globally
  2059 ** disabled. The default value may be changed by compiling with the
  2060 ** [SQLITE_USE_URI] symbol defined.)^
  2061 **
  2062 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
  2063 ** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
  2064 ** argument which is interpreted as a boolean in order to enable or disable
  2065 ** the use of covering indices for full table scans in the query optimizer.
  2066 ** ^The default setting is determined
  2067 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
  2068 ** if that compile-time option is omitted.
  2069 ** The ability to disable the use of covering indices for full table scans
  2070 ** is because some incorrectly coded legacy applications might malfunction
  2071 ** when the optimization is enabled.  Providing the ability to
  2072 ** disable the optimization allows the older, buggy application code to work
  2073 ** without change even with newer versions of SQLite.
  2074 **
  2075 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
  2076 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
  2077 ** <dd> These options are obsolete and should not be used by new code.
  2078 ** They are retained for backwards compatibility but are now no-ops.
  2079 ** </dd>
  2080 **
  2081 ** [[SQLITE_CONFIG_SQLLOG]]
  2082 ** <dt>SQLITE_CONFIG_SQLLOG
  2083 ** <dd>This option is only available if sqlite is compiled with the
  2084 ** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should
  2085 ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
  2086 ** The second should be of type (void*). The callback is invoked by the library
  2087 ** in three separate circumstances, identified by the value passed as the
  2088 ** fourth parameter. If the fourth parameter is 0, then the database connection
  2089 ** passed as the second argument has just been opened. The third argument
  2090 ** points to a buffer containing the name of the main database file. If the
  2091 ** fourth parameter is 1, then the SQL statement that the third parameter
  2092 ** points to has just been executed. Or, if the fourth parameter is 2, then
  2093 ** the connection being passed as the second parameter is being closed. The
  2094 ** third parameter is passed NULL In this case.  An example of using this
  2095 ** configuration option can be seen in the "test_sqllog.c" source file in
  2096 ** the canonical SQLite source tree.</dd>
  2097 **
  2098 ** [[SQLITE_CONFIG_MMAP_SIZE]]
  2099 ** <dt>SQLITE_CONFIG_MMAP_SIZE
  2100 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
  2101 ** that are the default mmap size limit (the default setting for
  2102 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
  2103 ** ^The default setting can be overridden by each database connection using
  2104 ** either the [PRAGMA mmap_size] command, or by using the
  2105 ** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size
  2106 ** will be silently truncated if necessary so that it does not exceed the
  2107 ** compile-time maximum mmap size set by the
  2108 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
  2109 ** ^If either argument to this option is negative, then that argument is
  2110 ** changed to its compile-time default.
  2111 **
  2112 ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
  2113 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
  2114 ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
  2115 ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
  2116 ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
  2117 ** that specifies the maximum size of the created heap.
  2118 **
  2119 ** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
  2120 ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
  2121 ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
  2122 ** is a pointer to an integer and writes into that integer the number of extra
  2123 ** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
  2124 ** The amount of extra space required can change depending on the compiler,
  2125 ** target platform, and SQLite version.
  2126 **
  2127 ** [[SQLITE_CONFIG_PMASZ]]
  2128 ** <dt>SQLITE_CONFIG_PMASZ
  2129 ** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
  2130 ** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
  2131 ** sorter to that integer.  The default minimum PMA Size is set by the
  2132 ** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched
  2133 ** to help with sort operations when multithreaded sorting
  2134 ** is enabled (using the [PRAGMA threads] command) and the amount of content
  2135 ** to be sorted exceeds the page size times the minimum of the
  2136 ** [PRAGMA cache_size] setting and this value.
  2137 **
  2138 ** [[SQLITE_CONFIG_STMTJRNL_SPILL]]
  2139 ** <dt>SQLITE_CONFIG_STMTJRNL_SPILL
  2140 ** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which
  2141 ** becomes the [statement journal] spill-to-disk threshold.  
  2142 ** [Statement journals] are held in memory until their size (in bytes)
  2143 ** exceeds this threshold, at which point they are written to disk.
  2144 ** Or if the threshold is -1, statement journals are always held
  2145 ** exclusively in memory.
  2146 ** Since many statement journals never become large, setting the spill
  2147 ** threshold to a value such as 64KiB can greatly reduce the amount of
  2148 ** I/O required to support statement rollback.
  2149 ** The default value for this setting is controlled by the
  2150 ** [SQLITE_STMTJRNL_SPILL] compile-time option.
  2151 ** </dl>
  2152 */
  2153 #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  2154 #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  2155 #define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  2156 #define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  2157 #define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
  2158 #define SQLITE_CONFIG_SCRATCH       6  /* void*, int sz, int N */
  2159 #define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */
  2160 #define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */
  2161 #define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */
  2162 #define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */
  2163 #define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */
  2164 /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ 
  2165 #define SQLITE_CONFIG_LOOKASIDE    13  /* int int */
  2166 #define SQLITE_CONFIG_PCACHE       14  /* no-op */
  2167 #define SQLITE_CONFIG_GETPCACHE    15  /* no-op */
  2168 #define SQLITE_CONFIG_LOG          16  /* xFunc, void* */
  2169 #define SQLITE_CONFIG_URI          17  /* int */
  2170 #define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */
  2171 #define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */
  2172 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */
  2173 #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  2174 #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
  2175 #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
  2176 #define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
  2177 #define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
  2178 #define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */
  2179 
  2180 /*
  2181 ** CAPI3REF: Database Connection Configuration Options
  2182 **
  2183 ** These constants are the available integer configuration options that
  2184 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  2185 **
  2186 ** New configuration options may be added in future releases of SQLite.
  2187 ** Existing configuration options might be discontinued.  Applications
  2188 ** should check the return code from [sqlite3_db_config()] to make sure that
  2189 ** the call worked.  ^The [sqlite3_db_config()] interface will return a
  2190 ** non-zero [error code] if a discontinued or unsupported configuration option
  2191 ** is invoked.
  2192 **
  2193 ** <dl>
  2194 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
  2195 ** <dd> ^This option takes three additional arguments that determine the 
  2196 ** [lookaside memory allocator] configuration for the [database connection].
  2197 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
  2198 ** pointer to a memory buffer to use for lookaside memory.
  2199 ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
  2200 ** may be NULL in which case SQLite will allocate the
  2201 ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
  2202 ** size of each lookaside buffer slot.  ^The third argument is the number of
  2203 ** slots.  The size of the buffer in the first argument must be greater than
  2204 ** or equal to the product of the second and third arguments.  The buffer
  2205 ** must be aligned to an 8-byte boundary.  ^If the second argument to
  2206 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
  2207 ** rounded down to the next smaller multiple of 8.  ^(The lookaside memory
  2208 ** configuration for a database connection can only be changed when that
  2209 ** connection is not currently using lookaside memory, or in other words
  2210 ** when the "current value" returned by
  2211 ** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.
  2212 ** Any attempt to change the lookaside memory configuration when lookaside
  2213 ** memory is in use leaves the configuration unchanged and returns 
  2214 ** [SQLITE_BUSY].)^</dd>
  2215 **
  2216 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
  2217 ** <dd> ^This option is used to enable or disable the enforcement of
  2218 ** [foreign key constraints].  There should be two additional arguments.
  2219 ** The first argument is an integer which is 0 to disable FK enforcement,
  2220 ** positive to enable FK enforcement or negative to leave FK enforcement
  2221 ** unchanged.  The second parameter is a pointer to an integer into which
  2222 ** is written 0 or 1 to indicate whether FK enforcement is off or on
  2223 ** following this call.  The second parameter may be a NULL pointer, in
  2224 ** which case the FK enforcement setting is not reported back. </dd>
  2225 **
  2226 ** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
  2227 ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
  2228 ** There should be two additional arguments.
  2229 ** The first argument is an integer which is 0 to disable triggers,
  2230 ** positive to enable triggers or negative to leave the setting unchanged.
  2231 ** The second parameter is a pointer to an integer into which
  2232 ** is written 0 or 1 to indicate whether triggers are disabled or enabled
  2233 ** following this call.  The second parameter may be a NULL pointer, in
  2234 ** which case the trigger setting is not reported back. </dd>
  2235 **
  2236 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
  2237 ** <dd> ^This option is used to enable or disable the two-argument
  2238 ** version of the [fts3_tokenizer()] function which is part of the
  2239 ** [FTS3] full-text search engine extension.
  2240 ** There should be two additional arguments.
  2241 ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
  2242 ** positive to enable fts3_tokenizer() or negative to leave the setting
  2243 ** unchanged.
  2244 ** The second parameter is a pointer to an integer into which
  2245 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
  2246 ** following this call.  The second parameter may be a NULL pointer, in
  2247 ** which case the new setting is not reported back. </dd>
  2248 **
  2249 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
  2250 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
  2251 ** interface independently of the [load_extension()] SQL function.
  2252 ** The [sqlite3_enable_load_extension()] API enables or disables both the
  2253 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
  2254 ** There should be two additional arguments.
  2255 ** When the first argument to this interface is 1, then only the C-API is
  2256 ** enabled and the SQL function remains disabled.  If the first argument to
  2257 ** this interface is 0, then both the C-API and the SQL function are disabled.
  2258 ** If the first argument is -1, then no changes are made to state of either the
  2259 ** C-API or the SQL function.
  2260 ** The second parameter is a pointer to an integer into which
  2261 ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
  2262 ** is disabled or enabled following this call.  The second parameter may
  2263 ** be a NULL pointer, in which case the new setting is not reported back.
  2264 ** </dd>
  2265 **
  2266 ** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
  2267 ** <dd> ^This option is used to change the name of the "main" database
  2268 ** schema.  ^The sole argument is a pointer to a constant UTF8 string
  2269 ** which will become the new schema name in place of "main".  ^SQLite
  2270 ** does not make a copy of the new main schema name string, so the application
  2271 ** must ensure that the argument passed into this DBCONFIG option is unchanged
  2272 ** until after the database connection closes.
  2273 ** </dd>
  2274 **
  2275 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
  2276 ** <dd> Usually, when a database in wal mode is closed or detached from a 
  2277 ** database handle, SQLite checks if this will mean that there are now no 
  2278 ** connections at all to the database. If so, it performs a checkpoint 
  2279 ** operation before closing the connection. This option may be used to
  2280 ** override this behaviour. The first parameter passed to this operation
  2281 ** is an integer - non-zero to disable checkpoints-on-close, or zero (the
  2282 ** default) to enable them. The second parameter is a pointer to an integer
  2283 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
  2284 ** have been disabled - 0 if they are not disabled, 1 if they are.
  2285 ** </dd>
  2286 **
  2287 ** </dl>
  2288 */
  2289 #define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
  2290 #define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
  2291 #define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
  2292 #define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */
  2293 #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
  2294 #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
  2295 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */
  2296 
  2297 
  2298 /*
  2299 ** CAPI3REF: Enable Or Disable Extended Result Codes
  2300 ** METHOD: sqlite3
  2301 **
  2302 ** ^The sqlite3_extended_result_codes() routine enables or disables the
  2303 ** [extended result codes] feature of SQLite. ^The extended result
  2304 ** codes are disabled by default for historical compatibility.
  2305 */
  2306 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
  2307 
  2308 /*
  2309 ** CAPI3REF: Last Insert Rowid
  2310 ** METHOD: sqlite3
  2311 **
  2312 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
  2313 ** has a unique 64-bit signed
  2314 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
  2315 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
  2316 ** names are not also used by explicitly declared columns. ^If
  2317 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
  2318 ** is another alias for the rowid.
  2319 **
  2320 ** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of
  2321 ** the most recent successful [INSERT] into a rowid table or [virtual table]
  2322 ** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not
  2323 ** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred 
  2324 ** on the database connection D, then sqlite3_last_insert_rowid(D) returns 
  2325 ** zero.
  2326 **
  2327 ** As well as being set automatically as rows are inserted into database
  2328 ** tables, the value returned by this function may be set explicitly by
  2329 ** [sqlite3_set_last_insert_rowid()]
  2330 **
  2331 ** Some virtual table implementations may INSERT rows into rowid tables as
  2332 ** part of committing a transaction (e.g. to flush data accumulated in memory
  2333 ** to disk). In this case subsequent calls to this function return the rowid
  2334 ** associated with these internal INSERT operations, which leads to 
  2335 ** unintuitive results. Virtual table implementations that do write to rowid
  2336 ** tables in this way can avoid this problem by restoring the original 
  2337 ** rowid value using [sqlite3_set_last_insert_rowid()] before returning 
  2338 ** control to the user.
  2339 **
  2340 ** ^(If an [INSERT] occurs within a trigger then this routine will 
  2341 ** return the [rowid] of the inserted row as long as the trigger is 
  2342 ** running. Once the trigger program ends, the value returned 
  2343 ** by this routine reverts to what it was before the trigger was fired.)^
  2344 **
  2345 ** ^An [INSERT] that fails due to a constraint violation is not a
  2346 ** successful [INSERT] and does not change the value returned by this
  2347 ** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
  2348 ** and INSERT OR ABORT make no changes to the return value of this
  2349 ** routine when their insertion fails.  ^(When INSERT OR REPLACE
  2350 ** encounters a constraint violation, it does not fail.  The
  2351 ** INSERT continues to completion after deleting rows that caused
  2352 ** the constraint problem so INSERT OR REPLACE will always change
  2353 ** the return value of this interface.)^
  2354 **
  2355 ** ^For the purposes of this routine, an [INSERT] is considered to
  2356 ** be successful even if it is subsequently rolled back.
  2357 **
  2358 ** This function is accessible to SQL statements via the
  2359 ** [last_insert_rowid() SQL function].
  2360 **
  2361 ** If a separate thread performs a new [INSERT] on the same
  2362 ** database connection while the [sqlite3_last_insert_rowid()]
  2363 ** function is running and thus changes the last insert [rowid],
  2364 ** then the value returned by [sqlite3_last_insert_rowid()] is
  2365 ** unpredictable and might not equal either the old or the new
  2366 ** last insert [rowid].
  2367 */
  2368 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
  2369 
  2370 /*
  2371 ** CAPI3REF: Set the Last Insert Rowid value.
  2372 ** METHOD: sqlite3
  2373 **
  2374 ** The sqlite3_set_last_insert_rowid(D, R) method allows the application to
  2375 ** set the value returned by calling sqlite3_last_insert_rowid(D) to R 
  2376 ** without inserting a row into the database.
  2377 */
  2378 SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
  2379 
  2380 /*
  2381 ** CAPI3REF: Count The Number Of Rows Modified
  2382 ** METHOD: sqlite3
  2383 **
  2384 ** ^This function returns the number of rows modified, inserted or
  2385 ** deleted by the most recently completed INSERT, UPDATE or DELETE
  2386 ** statement on the database connection specified by the only parameter.
  2387 ** ^Executing any other type of SQL statement does not modify the value
  2388 ** returned by this function.
  2389 **
  2390 ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
  2391 ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], 
  2392 ** [foreign key actions] or [REPLACE] constraint resolution are not counted.
  2393 ** 
  2394 ** Changes to a view that are intercepted by 
  2395 ** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value 
  2396 ** returned by sqlite3_changes() immediately after an INSERT, UPDATE or 
  2397 ** DELETE statement run on a view is always zero. Only changes made to real 
  2398 ** tables are counted.
  2399 **
  2400 ** Things are more complicated if the sqlite3_changes() function is
  2401 ** executed while a trigger program is running. This may happen if the
  2402 ** program uses the [changes() SQL function], or if some other callback
  2403 ** function invokes sqlite3_changes() directly. Essentially:
  2404 ** 
  2405 ** <ul>
  2406 **   <li> ^(Before entering a trigger program the value returned by
  2407 **        sqlite3_changes() function is saved. After the trigger program 
  2408 **        has finished, the original value is restored.)^
  2409 ** 
  2410 **   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE 
  2411 **        statement sets the value returned by sqlite3_changes() 
  2412 **        upon completion as normal. Of course, this value will not include 
  2413 **        any changes performed by sub-triggers, as the sqlite3_changes() 
  2414 **        value will be saved and restored after each sub-trigger has run.)^
  2415 ** </ul>
  2416 ** 
  2417 ** ^This means that if the changes() SQL function (or similar) is used
  2418 ** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
  2419 ** returns the value as set when the calling statement began executing.
  2420 ** ^If it is used by the second or subsequent such statement within a trigger 
  2421 ** program, the value returned reflects the number of rows modified by the 
  2422 ** previous INSERT, UPDATE or DELETE statement within the same trigger.
  2423 **
  2424 ** See also the [sqlite3_total_changes()] interface, the
  2425 ** [count_changes pragma], and the [changes() SQL function].
  2426 **
  2427 ** If a separate thread makes changes on the same database connection
  2428 ** while [sqlite3_changes()] is running then the value returned
  2429 ** is unpredictable and not meaningful.
  2430 */
  2431 SQLITE_API int sqlite3_changes(sqlite3*);
  2432 
  2433 /*
  2434 ** CAPI3REF: Total Number Of Rows Modified
  2435 ** METHOD: sqlite3
  2436 **
  2437 ** ^This function returns the total number of rows inserted, modified or
  2438 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
  2439 ** since the database connection was opened, including those executed as
  2440 ** part of trigger programs. ^Executing any other type of SQL statement
  2441 ** does not affect the value returned by sqlite3_total_changes().
  2442 ** 
  2443 ** ^Changes made as part of [foreign key actions] are included in the
  2444 ** count, but those made as part of REPLACE constraint resolution are
  2445 ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
  2446 ** are not counted.
  2447 ** 
  2448 ** See also the [sqlite3_changes()] interface, the
  2449 ** [count_changes pragma], and the [total_changes() SQL function].
  2450 **
  2451 ** If a separate thread makes changes on the same database connection
  2452 ** while [sqlite3_total_changes()] is running then the value
  2453 ** returned is unpredictable and not meaningful.
  2454 */
  2455 SQLITE_API int sqlite3_total_changes(sqlite3*);
  2456 
  2457 /*
  2458 ** CAPI3REF: Interrupt A Long-Running Query
  2459 ** METHOD: sqlite3
  2460 **
  2461 ** ^This function causes any pending database operation to abort and
  2462 ** return at its earliest opportunity. This routine is typically
  2463 ** called in response to a user action such as pressing "Cancel"
  2464 ** or Ctrl-C where the user wants a long query operation to halt
  2465 ** immediately.
  2466 **
  2467 ** ^It is safe to call this routine from a thread different from the
  2468 ** thread that is currently running the database operation.  But it
  2469 ** is not safe to call this routine with a [database connection] that
  2470 ** is closed or might close before sqlite3_interrupt() returns.
  2471 **
  2472 ** ^If an SQL operation is very nearly finished at the time when
  2473 ** sqlite3_interrupt() is called, then it might not have an opportunity
  2474 ** to be interrupted and might continue to completion.
  2475 **
  2476 ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
  2477 ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
  2478 ** that is inside an explicit transaction, then the entire transaction
  2479 ** will be rolled back automatically.
  2480 **
  2481 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
  2482 ** SQL statements on [database connection] D complete.  ^Any new SQL statements
  2483 ** that are started after the sqlite3_interrupt() call and before the 
  2484 ** running statements reaches zero are interrupted as if they had been
  2485 ** running prior to the sqlite3_interrupt() call.  ^New SQL statements
  2486 ** that are started after the running statement count reaches zero are
  2487 ** not effected by the sqlite3_interrupt().
  2488 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
  2489 ** SQL statements is a no-op and has no effect on SQL statements
  2490 ** that are started after the sqlite3_interrupt() call returns.
  2491 */
  2492 SQLITE_API void sqlite3_interrupt(sqlite3*);
  2493 
  2494 /*
  2495 ** CAPI3REF: Determine If An SQL Statement Is Complete
  2496 **
  2497 ** These routines are useful during command-line input to determine if the
  2498 ** currently entered text seems to form a complete SQL statement or
  2499 ** if additional input is needed before sending the text into
  2500 ** SQLite for parsing.  ^These routines return 1 if the input string
  2501 ** appears to be a complete SQL statement.  ^A statement is judged to be
  2502 ** complete if it ends with a semicolon token and is not a prefix of a
  2503 ** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within
  2504 ** string literals or quoted identifier names or comments are not
  2505 ** independent tokens (they are part of the token in which they are
  2506 ** embedded) and thus do not count as a statement terminator.  ^Whitespace
  2507 ** and comments that follow the final semicolon are ignored.
  2508 **
  2509 ** ^These routines return 0 if the statement is incomplete.  ^If a
  2510 ** memory allocation fails, then SQLITE_NOMEM is returned.
  2511 **
  2512 ** ^These routines do not parse the SQL statements thus
  2513 ** will not detect syntactically incorrect SQL.
  2514 **
  2515 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior 
  2516 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
  2517 ** automatically by sqlite3_complete16().  If that initialization fails,
  2518 ** then the return value from sqlite3_complete16() will be non-zero
  2519 ** regardless of whether or not the input SQL is complete.)^
  2520 **
  2521 ** The input to [sqlite3_complete()] must be a zero-terminated
  2522 ** UTF-8 string.
  2523 **
  2524 ** The input to [sqlite3_complete16()] must be a zero-terminated
  2525 ** UTF-16 string in native byte order.
  2526 */
  2527 SQLITE_API int sqlite3_complete(const char *sql);
  2528 SQLITE_API int sqlite3_complete16(const void *sql);
  2529 
  2530 /*
  2531 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
  2532 ** KEYWORDS: {busy-handler callback} {busy handler}
  2533 ** METHOD: sqlite3
  2534 **
  2535 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
  2536 ** that might be invoked with argument P whenever
  2537 ** an attempt is made to access a database table associated with
  2538 ** [database connection] D when another thread
  2539 ** or process has the table locked.
  2540 ** The sqlite3_busy_handler() interface is used to implement
  2541 ** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].
  2542 **
  2543 ** ^If the busy callback is NULL, then [SQLITE_BUSY]
  2544 ** is returned immediately upon encountering the lock.  ^If the busy callback
  2545 ** is not NULL, then the callback might be invoked with two arguments.
  2546 **
  2547 ** ^The first argument to the busy handler is a copy of the void* pointer which
  2548 ** is the third argument to sqlite3_busy_handler().  ^The second argument to
  2549 ** the busy handler callback is the number of times that the busy handler has
  2550 ** been invoked previously for the same locking event.  ^If the
  2551 ** busy callback returns 0, then no additional attempts are made to
  2552 ** access the database and [SQLITE_BUSY] is returned
  2553 ** to the application.
  2554 ** ^If the callback returns non-zero, then another attempt
  2555 ** is made to access the database and the cycle repeats.
  2556 **
  2557 ** The presence of a busy handler does not guarantee that it will be invoked
  2558 ** when there is lock contention. ^If SQLite determines that invoking the busy
  2559 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
  2560 ** to the application instead of invoking the 
  2561 ** busy handler.
  2562 ** Consider a scenario where one process is holding a read lock that
  2563 ** it is trying to promote to a reserved lock and
  2564 ** a second process is holding a reserved lock that it is trying
  2565 ** to promote to an exclusive lock.  The first process cannot proceed
  2566 ** because it is blocked by the second and the second process cannot
  2567 ** proceed because it is blocked by the first.  If both processes
  2568 ** invoke the busy handlers, neither will make any progress.  Therefore,
  2569 ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
  2570 ** will induce the first process to release its read lock and allow
  2571 ** the second process to proceed.
  2572 **
  2573 ** ^The default busy callback is NULL.
  2574 **
  2575 ** ^(There can only be a single busy handler defined for each
  2576 ** [database connection].  Setting a new busy handler clears any
  2577 ** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]
  2578 ** or evaluating [PRAGMA busy_timeout=N] will change the
  2579 ** busy handler and thus clear any previously set busy handler.
  2580 **
  2581 ** The busy callback should not take any actions which modify the
  2582 ** database connection that invoked the busy handler.  In other words,
  2583 ** the busy handler is not reentrant.  Any such actions
  2584 ** result in undefined behavior.
  2585 ** 
  2586 ** A busy handler must not close the database connection
  2587 ** or [prepared statement] that invoked the busy handler.
  2588 */
  2589 SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
  2590 
  2591 /*
  2592 ** CAPI3REF: Set A Busy Timeout
  2593 ** METHOD: sqlite3
  2594 **
  2595 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
  2596 ** for a specified amount of time when a table is locked.  ^The handler
  2597 ** will sleep multiple times until at least "ms" milliseconds of sleeping
  2598 ** have accumulated.  ^After at least "ms" milliseconds of sleeping,
  2599 ** the handler returns 0 which causes [sqlite3_step()] to return
  2600 ** [SQLITE_BUSY].
  2601 **
  2602 ** ^Calling this routine with an argument less than or equal to zero
  2603 ** turns off all busy handlers.
  2604 **
  2605 ** ^(There can only be a single busy handler for a particular
  2606 ** [database connection] at any given moment.  If another busy handler
  2607 ** was defined  (using [sqlite3_busy_handler()]) prior to calling
  2608 ** this routine, that other busy handler is cleared.)^
  2609 **
  2610 ** See also:  [PRAGMA busy_timeout]
  2611 */
  2612 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
  2613 
  2614 /*
  2615 ** CAPI3REF: Convenience Routines For Running Queries
  2616 ** METHOD: sqlite3
  2617 **
  2618 ** This is a legacy interface that is preserved for backwards compatibility.
  2619 ** Use of this interface is not recommended.
  2620 **
  2621 ** Definition: A <b>result table</b> is memory data structure created by the
  2622 ** [sqlite3_get_table()] interface.  A result table records the
  2623 ** complete query results from one or more queries.
  2624 **
  2625 ** The table conceptually has a number of rows and columns.  But
  2626 ** these numbers are not part of the result table itself.  These
  2627 ** numbers are obtained separately.  Let N be the number of rows
  2628 ** and M be the number of columns.
  2629 **
  2630 ** A result table is an array of pointers to zero-terminated UTF-8 strings.
  2631 ** There are (N+1)*M elements in the array.  The first M pointers point
  2632 ** to zero-terminated strings that  contain the names of the columns.
  2633 ** The remaining entries all point to query results.  NULL values result
  2634 ** in NULL pointers.  All other values are in their UTF-8 zero-terminated
  2635 ** string representation as returned by [sqlite3_column_text()].
  2636 **
  2637 ** A result table might consist of one or more memory allocations.
  2638 ** It is not safe to pass a result table directly to [sqlite3_free()].
  2639 ** A result table should be deallocated using [sqlite3_free_table()].
  2640 **
  2641 ** ^(As an example of the result table format, suppose a query result
  2642 ** is as follows:
  2643 **
  2644 ** <blockquote><pre>
  2645 **        Name        | Age
  2646 **        -----------------------
  2647 **        Alice       | 43
  2648 **        Bob         | 28
  2649 **        Cindy       | 21
  2650 ** </pre></blockquote>
  2651 **
  2652 ** There are two column (M==2) and three rows (N==3).  Thus the
  2653 ** result table has 8 entries.  Suppose the result table is stored
  2654 ** in an array names azResult.  Then azResult holds this content:
  2655 **
  2656 ** <blockquote><pre>
  2657 **        azResult&#91;0] = "Name";
  2658 **        azResult&#91;1] = "Age";
  2659 **        azResult&#91;2] = "Alice";
  2660 **        azResult&#91;3] = "43";
  2661 **        azResult&#91;4] = "Bob";
  2662 **        azResult&#91;5] = "28";
  2663 **        azResult&#91;6] = "Cindy";
  2664 **        azResult&#91;7] = "21";
  2665 ** </pre></blockquote>)^
  2666 **
  2667 ** ^The sqlite3_get_table() function evaluates one or more
  2668 ** semicolon-separated SQL statements in the zero-terminated UTF-8
  2669 ** string of its 2nd parameter and returns a result table to the
  2670 ** pointer given in its 3rd parameter.
  2671 **
  2672 ** After the application has finished with the result from sqlite3_get_table(),
  2673 ** it must pass the result table pointer to sqlite3_free_table() in order to
  2674 ** release the memory that was malloced.  Because of the way the
  2675 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
  2676 ** function must not try to call [sqlite3_free()] directly.  Only
  2677 ** [sqlite3_free_table()] is able to release the memory properly and safely.
  2678 **
  2679 ** The sqlite3_get_table() interface is implemented as a wrapper around
  2680 ** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access
  2681 ** to any internal data structures of SQLite.  It uses only the public
  2682 ** interface defined here.  As a consequence, errors that occur in the
  2683 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
  2684 ** reflected in subsequent calls to [sqlite3_errcode()] or
  2685 ** [sqlite3_errmsg()].
  2686 */
  2687 SQLITE_API int sqlite3_get_table(
  2688   sqlite3 *db,          /* An open database */
  2689   const char *zSql,     /* SQL to be evaluated */
  2690   char ***pazResult,    /* Results of the query */
  2691   int *pnRow,           /* Number of result rows written here */
  2692   int *pnColumn,        /* Number of result columns written here */
  2693   char **pzErrmsg       /* Error msg written here */
  2694 );
  2695 SQLITE_API void sqlite3_free_table(char **result);
  2696 
  2697 /*
  2698 ** CAPI3REF: Formatted String Printing Functions
  2699 **
  2700 ** These routines are work-alikes of the "printf()" family of functions
  2701 ** from the standard C library.
  2702 ** These routines understand most of the common K&R formatting options,
  2703 ** plus some additional non-standard formats, detailed below.
  2704 ** Note that some of the more obscure formatting options from recent
  2705 ** C-library standards are omitted from this implementation.
  2706 **
  2707 ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
  2708 ** results into memory obtained from [sqlite3_malloc()].
  2709 ** The strings returned by these two routines should be
  2710 ** released by [sqlite3_free()].  ^Both routines return a
  2711 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
  2712 ** memory to hold the resulting string.
  2713 **
  2714 ** ^(The sqlite3_snprintf() routine is similar to "snprintf()" from
  2715 ** the standard C library.  The result is written into the
  2716 ** buffer supplied as the second parameter whose size is given by
  2717 ** the first parameter. Note that the order of the
  2718 ** first two parameters is reversed from snprintf().)^  This is an
  2719 ** historical accident that cannot be fixed without breaking
  2720 ** backwards compatibility.  ^(Note also that sqlite3_snprintf()
  2721 ** returns a pointer to its buffer instead of the number of
  2722 ** characters actually written into the buffer.)^  We admit that
  2723 ** the number of characters written would be a more useful return
  2724 ** value but we cannot change the implementation of sqlite3_snprintf()
  2725 ** now without breaking compatibility.
  2726 **
  2727 ** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
  2728 ** guarantees that the buffer is always zero-terminated.  ^The first
  2729 ** parameter "n" is the total size of the buffer, including space for
  2730 ** the zero terminator.  So the longest string that can be completely
  2731 ** written will be n-1 characters.
  2732 **
  2733 ** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().
  2734 **
  2735 ** These routines all implement some additional formatting
  2736 ** options that are useful for constructing SQL statements.
  2737 ** All of the usual printf() formatting options apply.  In addition, there
  2738 ** is are "%q", "%Q", "%w" and "%z" options.
  2739 **
  2740 ** ^(The %q option works like %s in that it substitutes a nul-terminated
  2741 ** string from the argument list.  But %q also doubles every '\'' character.
  2742 ** %q is designed for use inside a string literal.)^  By doubling each '\''
  2743 ** character it escapes that character and allows it to be inserted into
  2744 ** the string.
  2745 **
  2746 ** For example, assume the string variable zText contains text as follows:
  2747 **
  2748 ** <blockquote><pre>
  2749 **  char *zText = "It's a happy day!";
  2750 ** </pre></blockquote>
  2751 **
  2752 ** One can use this text in an SQL statement as follows:
  2753 **
  2754 ** <blockquote><pre>
  2755 **  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
  2756 **  sqlite3_exec(db, zSQL, 0, 0, 0);
  2757 **  sqlite3_free(zSQL);
  2758 ** </pre></blockquote>
  2759 **
  2760 ** Because the %q format string is used, the '\'' character in zText
  2761 ** is escaped and the SQL generated is as follows:
  2762 **
  2763 ** <blockquote><pre>
  2764 **  INSERT INTO table1 VALUES('It''s a happy day!')
  2765 ** </pre></blockquote>
  2766 **
  2767 ** This is correct.  Had we used %s instead of %q, the generated SQL
  2768 ** would have looked like this:
  2769 **
  2770 ** <blockquote><pre>
  2771 **  INSERT INTO table1 VALUES('It's a happy day!');
  2772 ** </pre></blockquote>
  2773 **
  2774 ** This second example is an SQL syntax error.  As a general rule you should
  2775 ** always use %q instead of %s when inserting text into a string literal.
  2776 **
  2777 ** ^(The %Q option works like %q except it also adds single quotes around
  2778 ** the outside of the total string.  Additionally, if the parameter in the
  2779 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
  2780 ** single quotes).)^  So, for example, one could say:
  2781 **
  2782 ** <blockquote><pre>
  2783 **  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
  2784 **  sqlite3_exec(db, zSQL, 0, 0, 0);
  2785 **  sqlite3_free(zSQL);
  2786 ** </pre></blockquote>
  2787 **
  2788 ** The code above will render a correct SQL statement in the zSQL
  2789 ** variable even if the zText variable is a NULL pointer.
  2790 **
  2791 ** ^(The "%w" formatting option is like "%q" except that it expects to
  2792 ** be contained within double-quotes instead of single quotes, and it
  2793 ** escapes the double-quote character instead of the single-quote
  2794 ** character.)^  The "%w" formatting option is intended for safely inserting
  2795 ** table and column names into a constructed SQL statement.
  2796 **
  2797 ** ^(The "%z" formatting option works like "%s" but with the
  2798 ** addition that after the string has been read and copied into
  2799 ** the result, [sqlite3_free()] is called on the input string.)^
  2800 */
  2801 SQLITE_API char *sqlite3_mprintf(const char*,...);
  2802 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
  2803 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
  2804 SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
  2805 
  2806 /*
  2807 ** CAPI3REF: Memory Allocation Subsystem
  2808 **
  2809 ** The SQLite core uses these three routines for all of its own
  2810 ** internal memory allocation needs. "Core" in the previous sentence
  2811 ** does not include operating-system specific VFS implementation.  The
  2812 ** Windows VFS uses native malloc() and free() for some operations.
  2813 **
  2814 ** ^The sqlite3_malloc() routine returns a pointer to a block
  2815 ** of memory at least N bytes in length, where N is the parameter.
  2816 ** ^If sqlite3_malloc() is unable to obtain sufficient free
  2817 ** memory, it returns a NULL pointer.  ^If the parameter N to
  2818 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
  2819 ** a NULL pointer.
  2820 **
  2821 ** ^The sqlite3_malloc64(N) routine works just like
  2822 ** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
  2823 ** of a signed 32-bit integer.
  2824 **
  2825 ** ^Calling sqlite3_free() with a pointer previously returned
  2826 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
  2827 ** that it might be reused.  ^The sqlite3_free() routine is
  2828 ** a no-op if is called with a NULL pointer.  Passing a NULL pointer
  2829 ** to sqlite3_free() is harmless.  After being freed, memory
  2830 ** should neither be read nor written.  Even reading previously freed
  2831 ** memory might result in a segmentation fault or other severe error.
  2832 ** Memory corruption, a segmentation fault, or other severe error
  2833 ** might result if sqlite3_free() is called with a non-NULL pointer that
  2834 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
  2835 **
  2836 ** ^The sqlite3_realloc(X,N) interface attempts to resize a
  2837 ** prior memory allocation X to be at least N bytes.
  2838 ** ^If the X parameter to sqlite3_realloc(X,N)
  2839 ** is a NULL pointer then its behavior is identical to calling
  2840 ** sqlite3_malloc(N).
  2841 ** ^If the N parameter to sqlite3_realloc(X,N) is zero or
  2842 ** negative then the behavior is exactly the same as calling
  2843 ** sqlite3_free(X).
  2844 ** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
  2845 ** of at least N bytes in size or NULL if insufficient memory is available.
  2846 ** ^If M is the size of the prior allocation, then min(N,M) bytes
  2847 ** of the prior allocation are copied into the beginning of buffer returned
  2848 ** by sqlite3_realloc(X,N) and the prior allocation is freed.
  2849 ** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
  2850 ** prior allocation is not freed.
  2851 **
  2852 ** ^The sqlite3_realloc64(X,N) interfaces works the same as
  2853 ** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
  2854 ** of a 32-bit signed integer.
  2855 **
  2856 ** ^If X is a memory allocation previously obtained from sqlite3_malloc(),
  2857 ** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
  2858 ** sqlite3_msize(X) returns the size of that memory allocation in bytes.
  2859 ** ^The value returned by sqlite3_msize(X) might be larger than the number
  2860 ** of bytes requested when X was allocated.  ^If X is a NULL pointer then
  2861 ** sqlite3_msize(X) returns zero.  If X points to something that is not
  2862 ** the beginning of memory allocation, or if it points to a formerly
  2863 ** valid memory allocation that has now been freed, then the behavior
  2864 ** of sqlite3_msize(X) is undefined and possibly harmful.
  2865 **
  2866 ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
  2867 ** sqlite3_malloc64(), and sqlite3_realloc64()
  2868 ** is always aligned to at least an 8 byte boundary, or to a
  2869 ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
  2870 ** option is used.
  2871 **
  2872 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
  2873 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
  2874 ** implementation of these routines to be omitted.  That capability
  2875 ** is no longer provided.  Only built-in memory allocators can be used.
  2876 **
  2877 ** Prior to SQLite version 3.7.10, the Windows OS interface layer called
  2878 ** the system malloc() and free() directly when converting
  2879 ** filenames between the UTF-8 encoding used by SQLite
  2880 ** and whatever filename encoding is used by the particular Windows
  2881 ** installation.  Memory allocation errors were detected, but
  2882 ** they were reported back as [SQLITE_CANTOPEN] or
  2883 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
  2884 **
  2885 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
  2886 ** must be either NULL or else pointers obtained from a prior
  2887 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
  2888 ** not yet been released.
  2889 **
  2890 ** The application must not read or write any part of
  2891 ** a block of memory after it has been released using
  2892 ** [sqlite3_free()] or [sqlite3_realloc()].
  2893 */
  2894 SQLITE_API void *sqlite3_malloc(int);
  2895 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
  2896 SQLITE_API void *sqlite3_realloc(void*, int);
  2897 SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
  2898 SQLITE_API void sqlite3_free(void*);
  2899 SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
  2900 
  2901 /*
  2902 ** CAPI3REF: Memory Allocator Statistics
  2903 **
  2904 ** SQLite provides these two interfaces for reporting on the status
  2905 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
  2906 ** routines, which form the built-in memory allocation subsystem.
  2907 **
  2908 ** ^The [sqlite3_memory_used()] routine returns the number of bytes
  2909 ** of memory currently outstanding (malloced but not freed).
  2910 ** ^The [sqlite3_memory_highwater()] routine returns the maximum
  2911 ** value of [sqlite3_memory_used()] since the high-water mark
  2912 ** was last reset.  ^The values returned by [sqlite3_memory_used()] and
  2913 ** [sqlite3_memory_highwater()] include any overhead
  2914 ** added by SQLite in its implementation of [sqlite3_malloc()],
  2915 ** but not overhead added by the any underlying system library
  2916 ** routines that [sqlite3_malloc()] may call.
  2917 **
  2918 ** ^The memory high-water mark is reset to the current value of
  2919 ** [sqlite3_memory_used()] if and only if the parameter to
  2920 ** [sqlite3_memory_highwater()] is true.  ^The value returned
  2921 ** by [sqlite3_memory_highwater(1)] is the high-water mark
  2922 ** prior to the reset.
  2923 */
  2924 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
  2925 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
  2926 
  2927 /*
  2928 ** CAPI3REF: Pseudo-Random Number Generator
  2929 **
  2930 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
  2931 ** select random [ROWID | ROWIDs] when inserting new records into a table that
  2932 ** already uses the largest possible [ROWID].  The PRNG is also used for
  2933 ** the build-in random() and randomblob() SQL functions.  This interface allows
  2934 ** applications to access the same PRNG for other purposes.
  2935 **
  2936 ** ^A call to this routine stores N bytes of randomness into buffer P.
  2937 ** ^The P parameter can be a NULL pointer.
  2938 **
  2939 ** ^If this routine has not been previously called or if the previous
  2940 ** call had N less than one or a NULL pointer for P, then the PRNG is
  2941 ** seeded using randomness obtained from the xRandomness method of
  2942 ** the default [sqlite3_vfs] object.
  2943 ** ^If the previous call to this routine had an N of 1 or more and a
  2944 ** non-NULL P then the pseudo-randomness is generated
  2945 ** internally and without recourse to the [sqlite3_vfs] xRandomness
  2946 ** method.
  2947 */
  2948 SQLITE_API void sqlite3_randomness(int N, void *P);
  2949 
  2950 /*
  2951 ** CAPI3REF: Compile-Time Authorization Callbacks
  2952 ** METHOD: sqlite3
  2953 ** KEYWORDS: {authorizer callback}
  2954 **
  2955 ** ^This routine registers an authorizer callback with a particular
  2956 ** [database connection], supplied in the first argument.
  2957 ** ^The authorizer callback is invoked as SQL statements are being compiled
  2958 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
  2959 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various
  2960 ** points during the compilation process, as logic is being created
  2961 ** to perform various actions, the authorizer callback is invoked to
  2962 ** see if those actions are allowed.  ^The authorizer callback should
  2963 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
  2964 ** specific action but allow the SQL statement to continue to be
  2965 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
  2966 ** rejected with an error.  ^If the authorizer callback returns
  2967 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
  2968 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
  2969 ** the authorizer will fail with an error message.
  2970 **
  2971 ** When the callback returns [SQLITE_OK], that means the operation
  2972 ** requested is ok.  ^When the callback returns [SQLITE_DENY], the
  2973 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
  2974 ** authorizer will fail with an error message explaining that
  2975 ** access is denied. 
  2976 **
  2977 ** ^The first parameter to the authorizer callback is a copy of the third
  2978 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
  2979 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
  2980 ** the particular action to be authorized. ^The third through sixth parameters
  2981 ** to the callback are either NULL pointers or zero-terminated strings
  2982 ** that contain additional details about the action to be authorized.
  2983 ** Applications must always be prepared to encounter a NULL pointer in any
  2984 ** of the third through the sixth parameters of the authorization callback.
  2985 **
  2986 ** ^If the action code is [SQLITE_READ]
  2987 ** and the callback returns [SQLITE_IGNORE] then the
  2988 ** [prepared statement] statement is constructed to substitute
  2989 ** a NULL value in place of the table column that would have
  2990 ** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]
  2991 ** return can be used to deny an untrusted user access to individual
  2992 ** columns of a table.
  2993 ** ^When a table is referenced by a [SELECT] but no column values are
  2994 ** extracted from that table (for example in a query like
  2995 ** "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback
  2996 ** is invoked once for that table with a column name that is an empty string.
  2997 ** ^If the action code is [SQLITE_DELETE] and the callback returns
  2998 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
  2999 ** [truncate optimization] is disabled and all rows are deleted individually.
  3000 **
  3001 ** An authorizer is used when [sqlite3_prepare | preparing]
  3002 ** SQL statements from an untrusted source, to ensure that the SQL statements
  3003 ** do not try to access data they are not allowed to see, or that they do not
  3004 ** try to execute malicious statements that damage the database.  For
  3005 ** example, an application may allow a user to enter arbitrary
  3006 ** SQL queries for evaluation by a database.  But the application does
  3007 ** not want the user to be able to make arbitrary changes to the
  3008 ** database.  An authorizer could then be put in place while the
  3009 ** user-entered SQL is being [sqlite3_prepare | prepared] that
  3010 ** disallows everything except [SELECT] statements.
  3011 **
  3012 ** Applications that need to process SQL from untrusted sources
  3013 ** might also consider lowering resource limits using [sqlite3_limit()]
  3014 ** and limiting database size using the [max_page_count] [PRAGMA]
  3015 ** in addition to using an authorizer.
  3016 **
  3017 ** ^(Only a single authorizer can be in place on a database connection
  3018 ** at a time.  Each call to sqlite3_set_authorizer overrides the
  3019 ** previous call.)^  ^Disable the authorizer by installing a NULL callback.
  3020 ** The authorizer is disabled by default.
  3021 **
  3022 ** The authorizer callback must not do anything that will modify
  3023 ** the database connection that invoked the authorizer callback.
  3024 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  3025 ** database connections for the meaning of "modify" in this paragraph.
  3026 **
  3027 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
  3028 ** statement might be re-prepared during [sqlite3_step()] due to a 
  3029 ** schema change.  Hence, the application should ensure that the
  3030 ** correct authorizer callback remains in place during the [sqlite3_step()].
  3031 **
  3032 ** ^Note that the authorizer callback is invoked only during
  3033 ** [sqlite3_prepare()] or its variants.  Authorization is not
  3034 ** performed during statement evaluation in [sqlite3_step()], unless
  3035 ** as stated in the previous paragraph, sqlite3_step() invokes
  3036 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
  3037 */
  3038 SQLITE_API int sqlite3_set_authorizer(
  3039   sqlite3*,
  3040   int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
  3041   void *pUserData
  3042 );
  3043 
  3044 /*
  3045 ** CAPI3REF: Authorizer Return Codes
  3046 **
  3047 ** The [sqlite3_set_authorizer | authorizer callback function] must
  3048 ** return either [SQLITE_OK] or one of these two constants in order
  3049 ** to signal SQLite whether or not the action is permitted.  See the
  3050 ** [sqlite3_set_authorizer | authorizer documentation] for additional
  3051 ** information.
  3052 **
  3053 ** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]
  3054 ** returned from the [sqlite3_vtab_on_conflict()] interface.
  3055 */
  3056 #define SQLITE_DENY   1   /* Abort the SQL statement with an error */
  3057 #define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
  3058 
  3059 /*
  3060 ** CAPI3REF: Authorizer Action Codes
  3061 **
  3062 ** The [sqlite3_set_authorizer()] interface registers a callback function
  3063 ** that is invoked to authorize certain SQL statement actions.  The
  3064 ** second parameter to the callback is an integer code that specifies
  3065 ** what action is being authorized.  These are the integer action codes that
  3066 ** the authorizer callback may be passed.
  3067 **
  3068 ** These action code values signify what kind of operation is to be
  3069 ** authorized.  The 3rd and 4th parameters to the authorization
  3070 ** callback function will be parameters or NULL depending on which of these
  3071 ** codes is used as the second parameter.  ^(The 5th parameter to the
  3072 ** authorizer callback is the name of the database ("main", "temp",
  3073 ** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback
  3074 ** is the name of the inner-most trigger or view that is responsible for
  3075 ** the access attempt or NULL if this access attempt is directly from
  3076 ** top-level SQL code.
  3077 */
  3078 /******************************************* 3rd ************ 4th ***********/
  3079 #define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
  3080 #define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */
  3081 #define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */
  3082 #define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */
  3083 #define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */
  3084 #define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */
  3085 #define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */
  3086 #define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */
  3087 #define SQLITE_DELETE                9   /* Table Name      NULL            */
  3088 #define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */
  3089 #define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */
  3090 #define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */
  3091 #define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */
  3092 #define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */
  3093 #define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */
  3094 #define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */
  3095 #define SQLITE_DROP_VIEW            17   /* View Name       NULL            */
  3096 #define SQLITE_INSERT               18   /* Table Name      NULL            */
  3097 #define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */
  3098 #define SQLITE_READ                 20   /* Table Name      Column Name     */
  3099 #define SQLITE_SELECT               21   /* NULL            NULL            */
  3100 #define SQLITE_TRANSACTION          22   /* Operation       NULL            */
  3101 #define SQLITE_UPDATE               23   /* Table Name      Column Name     */
  3102 #define SQLITE_ATTACH               24   /* Filename        NULL            */
  3103 #define SQLITE_DETACH               25   /* Database Name   NULL            */
  3104 #define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */
  3105 #define SQLITE_REINDEX              27   /* Index Name      NULL            */
  3106 #define SQLITE_ANALYZE              28   /* Table Name      NULL            */
  3107 #define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */
  3108 #define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */
  3109 #define SQLITE_FUNCTION             31   /* NULL            Function Name   */
  3110 #define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */
  3111 #define SQLITE_COPY                  0   /* No longer used */
  3112 #define SQLITE_RECURSIVE            33   /* NULL            NULL            */
  3113 
  3114 /*
  3115 ** CAPI3REF: Tracing And Profiling Functions
  3116 ** METHOD: sqlite3
  3117 **
  3118 ** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
  3119 ** instead of the routines described here.
  3120 **
  3121 ** These routines register callback functions that can be used for
  3122 ** tracing and profiling the execution of SQL statements.
  3123 **
  3124 ** ^The callback function registered by sqlite3_trace() is invoked at
  3125 ** various times when an SQL statement is being run by [sqlite3_step()].
  3126 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
  3127 ** SQL statement text as the statement first begins executing.
  3128 ** ^(Additional sqlite3_trace() callbacks might occur
  3129 ** as each triggered subprogram is entered.  The callbacks for triggers
  3130 ** contain a UTF-8 SQL comment that identifies the trigger.)^
  3131 **
  3132 ** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit
  3133 ** the length of [bound parameter] expansion in the output of sqlite3_trace().
  3134 **
  3135 ** ^The callback function registered by sqlite3_profile() is invoked
  3136 ** as each SQL statement finishes.  ^The profile callback contains
  3137 ** the original statement text and an estimate of wall-clock time
  3138 ** of how long that statement took to run.  ^The profile callback
  3139 ** time is in units of nanoseconds, however the current implementation
  3140 ** is only capable of millisecond resolution so the six least significant
  3141 ** digits in the time are meaningless.  Future versions of SQLite
  3142 ** might provide greater resolution on the profiler callback.  The
  3143 ** sqlite3_profile() function is considered experimental and is
  3144 ** subject to change in future versions of SQLite.
  3145 */
  3146 SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,
  3147    void(*xTrace)(void*,const char*), void*);
  3148 SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,
  3149    void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
  3150 
  3151 /*
  3152 ** CAPI3REF: SQL Trace Event Codes
  3153 ** KEYWORDS: SQLITE_TRACE
  3154 **
  3155 ** These constants identify classes of events that can be monitored
  3156 ** using the [sqlite3_trace_v2()] tracing logic.  The third argument
  3157 ** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
  3158 ** the following constants.  ^The first argument to the trace callback
  3159 ** is one of the following constants.
  3160 **
  3161 ** New tracing constants may be added in future releases.
  3162 **
  3163 ** ^A trace callback has four arguments: xCallback(T,C,P,X).
  3164 ** ^The T argument is one of the integer type codes above.
  3165 ** ^The C argument is a copy of the context pointer passed in as the
  3166 ** fourth argument to [sqlite3_trace_v2()].
  3167 ** The P and X arguments are pointers whose meanings depend on T.
  3168 **
  3169 ** <dl>
  3170 ** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
  3171 ** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
  3172 ** first begins running and possibly at other times during the
  3173 ** execution of the prepared statement, such as at the start of each
  3174 ** trigger subprogram. ^The P argument is a pointer to the
  3175 ** [prepared statement]. ^The X argument is a pointer to a string which
  3176 ** is the unexpanded SQL text of the prepared statement or an SQL comment 
  3177 ** that indicates the invocation of a trigger.  ^The callback can compute
  3178 ** the same text that would have been returned by the legacy [sqlite3_trace()]
  3179 ** interface by using the X argument when X begins with "--" and invoking
  3180 ** [sqlite3_expanded_sql(P)] otherwise.
  3181 **
  3182 ** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
  3183 ** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
  3184 ** information as is provided by the [sqlite3_profile()] callback.
  3185 ** ^The P argument is a pointer to the [prepared statement] and the
  3186 ** X argument points to a 64-bit integer which is the estimated of
  3187 ** the number of nanosecond that the prepared statement took to run.
  3188 ** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
  3189 **
  3190 ** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
  3191 ** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
  3192 ** statement generates a single row of result.  
  3193 ** ^The P argument is a pointer to the [prepared statement] and the
  3194 ** X argument is unused.
  3195 **
  3196 ** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
  3197 ** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
  3198 ** connection closes.
  3199 ** ^The P argument is a pointer to the [database connection] object
  3200 ** and the X argument is unused.
  3201 ** </dl>
  3202 */
  3203 #define SQLITE_TRACE_STMT       0x01
  3204 #define SQLITE_TRACE_PROFILE    0x02
  3205 #define SQLITE_TRACE_ROW        0x04
  3206 #define SQLITE_TRACE_CLOSE      0x08
  3207 
  3208 /*
  3209 ** CAPI3REF: SQL Trace Hook
  3210 ** METHOD: sqlite3
  3211 **
  3212 ** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
  3213 ** function X against [database connection] D, using property mask M
  3214 ** and context pointer P.  ^If the X callback is
  3215 ** NULL or if the M mask is zero, then tracing is disabled.  The
  3216 ** M argument should be the bitwise OR-ed combination of
  3217 ** zero or more [SQLITE_TRACE] constants.
  3218 **
  3219 ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides 
  3220 ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
  3221 **
  3222 ** ^The X callback is invoked whenever any of the events identified by 
  3223 ** mask M occur.  ^The integer return value from the callback is currently
  3224 ** ignored, though this may change in future releases.  Callback
  3225 ** implementations should return zero to ensure future compatibility.
  3226 **
  3227 ** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
  3228 ** ^The T argument is one of the [SQLITE_TRACE]
  3229 ** constants to indicate why the callback was invoked.
  3230 ** ^The C argument is a copy of the context pointer.
  3231 ** The P and X arguments are pointers whose meanings depend on T.
  3232 **
  3233 ** The sqlite3_trace_v2() interface is intended to replace the legacy
  3234 ** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
  3235 ** are deprecated.
  3236 */
  3237 SQLITE_API int sqlite3_trace_v2(
  3238   sqlite3*,
  3239   unsigned uMask,
  3240   int(*xCallback)(unsigned,void*,void*,void*),
  3241   void *pCtx
  3242 );
  3243 
  3244 /*
  3245 ** CAPI3REF: Query Progress Callbacks
  3246 ** METHOD: sqlite3
  3247 **
  3248 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
  3249 ** function X to be invoked periodically during long running calls to
  3250 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
  3251 ** database connection D.  An example use for this
  3252 ** interface is to keep a GUI updated during a large query.
  3253 **
  3254 ** ^The parameter P is passed through as the only parameter to the 
  3255 ** callback function X.  ^The parameter N is the approximate number of 
  3256 ** [virtual machine instructions] that are evaluated between successive
  3257 ** invocations of the callback X.  ^If N is less than one then the progress
  3258 ** handler is disabled.
  3259 **
  3260 ** ^Only a single progress handler may be defined at one time per
  3261 ** [database connection]; setting a new progress handler cancels the
  3262 ** old one.  ^Setting parameter X to NULL disables the progress handler.
  3263 ** ^The progress handler is also disabled by setting N to a value less
  3264 ** than 1.
  3265 **
  3266 ** ^If the progress callback returns non-zero, the operation is
  3267 ** interrupted.  This feature can be used to implement a
  3268 ** "Cancel" button on a GUI progress dialog box.
  3269 **
  3270 ** The progress handler callback must not do anything that will modify
  3271 ** the database connection that invoked the progress handler.
  3272 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  3273 ** database connections for the meaning of "modify" in this paragraph.
  3274 **
  3275 */
  3276 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
  3277 
  3278 /*
  3279 ** CAPI3REF: Opening A New Database Connection
  3280 ** CONSTRUCTOR: sqlite3
  3281 **
  3282 ** ^These routines open an SQLite database file as specified by the 
  3283 ** filename argument. ^The filename argument is interpreted as UTF-8 for
  3284 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
  3285 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
  3286 ** returned in *ppDb, even if an error occurs.  The only exception is that
  3287 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
  3288 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
  3289 ** object.)^ ^(If the database is opened (and/or created) successfully, then
  3290 ** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The
  3291 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
  3292 ** an English language description of the error following a failure of any
  3293 ** of the sqlite3_open() routines.
  3294 **
  3295 ** ^The default encoding will be UTF-8 for databases created using
  3296 ** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases
  3297 ** created using sqlite3_open16() will be UTF-16 in the native byte order.
  3298 **
  3299 ** Whether or not an error occurs when it is opened, resources
  3300 ** associated with the [database connection] handle should be released by
  3301 ** passing it to [sqlite3_close()] when it is no longer required.
  3302 **
  3303 ** The sqlite3_open_v2() interface works like sqlite3_open()
  3304 ** except that it accepts two additional parameters for additional control
  3305 ** over the new database connection.  ^(The flags parameter to
  3306 ** sqlite3_open_v2() can take one of
  3307 ** the following three values, optionally combined with the 
  3308 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
  3309 ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^
  3310 **
  3311 ** <dl>
  3312 ** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
  3313 ** <dd>The database is opened in read-only mode.  If the database does not
  3314 ** already exist, an error is returned.</dd>)^
  3315 **
  3316 ** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
  3317 ** <dd>The database is opened for reading and writing if possible, or reading
  3318 ** only if the file is write protected by the operating system.  In either
  3319 ** case the database must already exist, otherwise an error is returned.</dd>)^
  3320 **
  3321 ** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
  3322 ** <dd>The database is opened for reading and writing, and is created if
  3323 ** it does not already exist. This is the behavior that is always used for
  3324 ** sqlite3_open() and sqlite3_open16().</dd>)^
  3325 ** </dl>
  3326 **
  3327 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
  3328 ** combinations shown above optionally combined with other
  3329 ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
  3330 ** then the behavior is undefined.
  3331 **
  3332 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
  3333 ** opens in the multi-thread [threading mode] as long as the single-thread
  3334 ** mode has not been set at compile-time or start-time.  ^If the
  3335 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
  3336 ** in the serialized [threading mode] unless single-thread was
  3337 ** previously selected at compile-time or start-time.
  3338 ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
  3339 ** eligible to use [shared cache mode], regardless of whether or not shared
  3340 ** cache is enabled using [sqlite3_enable_shared_cache()].  ^The
  3341 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
  3342 ** participate in [shared cache mode] even if it is enabled.
  3343 **
  3344 ** ^The fourth parameter to sqlite3_open_v2() is the name of the
  3345 ** [sqlite3_vfs] object that defines the operating system interface that
  3346 ** the new database connection should use.  ^If the fourth parameter is
  3347 ** a NULL pointer then the default [sqlite3_vfs] object is used.
  3348 **
  3349 ** ^If the filename is ":memory:", then a private, temporary in-memory database
  3350 ** is created for the connection.  ^This in-memory database will vanish when
  3351 ** the database connection is closed.  Future versions of SQLite might
  3352 ** make use of additional special filenames that begin with the ":" character.
  3353 ** It is recommended that when a database filename actually does begin with
  3354 ** a ":" character you should prefix the filename with a pathname such as
  3355 ** "./" to avoid ambiguity.
  3356 **
  3357 ** ^If the filename is an empty string, then a private, temporary
  3358 ** on-disk database will be created.  ^This private database will be
  3359 ** automatically deleted as soon as the database connection is closed.
  3360 **
  3361 ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
  3362 **
  3363 ** ^If [URI filename] interpretation is enabled, and the filename argument
  3364 ** begins with "file:", then the filename is interpreted as a URI. ^URI
  3365 ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
  3366 ** set in the fourth argument to sqlite3_open_v2(), or if it has
  3367 ** been enabled globally using the [SQLITE_CONFIG_URI] option with the
  3368 ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
  3369 ** As of SQLite version 3.7.7, URI filename interpretation is turned off
  3370 ** by default, but future releases of SQLite might enable URI filename
  3371 ** interpretation by default.  See "[URI filenames]" for additional
  3372 ** information.
  3373 **
  3374 ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
  3375 ** authority, then it must be either an empty string or the string 
  3376 ** "localhost". ^If the authority is not an empty string or "localhost", an 
  3377 ** error is returned to the caller. ^The fragment component of a URI, if 
  3378 ** present, is ignored.
  3379 **
  3380 ** ^SQLite uses the path component of the URI as the name of the disk file
  3381 ** which contains the database. ^If the path begins with a '/' character, 
  3382 ** then it is interpreted as an absolute path. ^If the path does not begin 
  3383 ** with a '/' (meaning that the authority section is omitted from the URI)
  3384 ** then the path is interpreted as a relative path. 
  3385 ** ^(On windows, the first component of an absolute path 
  3386 ** is a drive specification (e.g. "C:").)^
  3387 **
  3388 ** [[core URI query parameters]]
  3389 ** The query component of a URI may contain parameters that are interpreted
  3390 ** either by SQLite itself, or by a [VFS | custom VFS implementation].
  3391 ** SQLite and its built-in [VFSes] interpret the
  3392 ** following query parameters:
  3393 **
  3394 ** <ul>
  3395 **   <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
  3396 **     a VFS object that provides the operating system interface that should
  3397 **     be used to access the database file on disk. ^If this option is set to
  3398 **     an empty string the default VFS object is used. ^Specifying an unknown
  3399 **     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is
  3400 **     present, then the VFS specified by the option takes precedence over
  3401 **     the value passed as the fourth parameter to sqlite3_open_v2().
  3402 **
  3403 **   <li> <b>mode</b>: ^(The mode parameter may be set to either "ro", "rw",
  3404 **     "rwc", or "memory". Attempting to set it to any other value is
  3405 **     an error)^. 
  3406 **     ^If "ro" is specified, then the database is opened for read-only 
  3407 **     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the 
  3408 **     third argument to sqlite3_open_v2(). ^If the mode option is set to 
  3409 **     "rw", then the database is opened for read-write (but not create) 
  3410 **     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had 
  3411 **     been set. ^Value "rwc" is equivalent to setting both 
  3412 **     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is
  3413 **     set to "memory" then a pure [in-memory database] that never reads
  3414 **     or writes from disk is used. ^It is an error to specify a value for
  3415 **     the mode parameter that is less restrictive than that specified by
  3416 **     the flags passed in the third parameter to sqlite3_open_v2().
  3417 **
  3418 **   <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or
  3419 **     "private". ^Setting it to "shared" is equivalent to setting the
  3420 **     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
  3421 **     sqlite3_open_v2(). ^Setting the cache parameter to "private" is 
  3422 **     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
  3423 **     ^If sqlite3_open_v2() is used and the "cache" parameter is present in
  3424 **     a URI filename, its value overrides any behavior requested by setting
  3425 **     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
  3426 **
  3427 **  <li> <b>psow</b>: ^The psow parameter indicates whether or not the
  3428 **     [powersafe overwrite] property does or does not apply to the
  3429 **     storage media on which the database file resides.
  3430 **
  3431 **  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
  3432 **     which if set disables file locking in rollback journal modes.  This
  3433 **     is useful for accessing a database on a filesystem that does not
  3434 **     support locking.  Caution:  Database corruption might result if two
  3435 **     or more processes write to the same database and any one of those
  3436 **     processes uses nolock=1.
  3437 **
  3438 **  <li> <b>immutable</b>: ^The immutable parameter is a boolean query
  3439 **     parameter that indicates that the database file is stored on
  3440 **     read-only media.  ^When immutable is set, SQLite assumes that the
  3441 **     database file cannot be changed, even by a process with higher
  3442 **     privilege, and so the database is opened read-only and all locking
  3443 **     and change detection is disabled.  Caution: Setting the immutable
  3444 **     property on a database file that does in fact change can result
  3445 **     in incorrect query results and/or [SQLITE_CORRUPT] errors.
  3446 **     See also: [SQLITE_IOCAP_IMMUTABLE].
  3447 **       
  3448 ** </ul>
  3449 **
  3450 ** ^Specifying an unknown parameter in the query component of a URI is not an
  3451 ** error.  Future versions of SQLite might understand additional query
  3452 ** parameters.  See "[query parameters with special meaning to SQLite]" for
  3453 ** additional information.
  3454 **
  3455 ** [[URI filename examples]] <h3>URI filename examples</h3>
  3456 **
  3457 ** <table border="1" align=center cellpadding=5>
  3458 ** <tr><th> URI filenames <th> Results
  3459 ** <tr><td> file:data.db <td> 
  3460 **          Open the file "data.db" in the current directory.
  3461 ** <tr><td> file:/home/fred/data.db<br>
  3462 **          file:///home/fred/data.db <br> 
  3463 **          file://localhost/home/fred/data.db <br> <td> 
  3464 **          Open the database file "/home/fred/data.db".
  3465 ** <tr><td> file://darkstar/home/fred/data.db <td> 
  3466 **          An error. "darkstar" is not a recognized authority.
  3467 ** <tr><td style="white-space:nowrap"> 
  3468 **          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db
  3469 **     <td> Windows only: Open the file "data.db" on fred's desktop on drive
  3470 **          C:. Note that the %20 escaping in this example is not strictly 
  3471 **          necessary - space characters can be used literally
  3472 **          in URI filenames.
  3473 ** <tr><td> file:data.db?mode=ro&cache=private <td> 
  3474 **          Open file "data.db" in the current directory for read-only access.
  3475 **          Regardless of whether or not shared-cache mode is enabled by
  3476 **          default, use a private cache.
  3477 ** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>
  3478 **          Open file "/home/fred/data.db". Use the special VFS "unix-dotfile"
  3479 **          that uses dot-files in place of posix advisory locking.
  3480 ** <tr><td> file:data.db?mode=readonly <td> 
  3481 **          An error. "readonly" is not a valid option for the "mode" parameter.
  3482 ** </table>
  3483 **
  3484 ** ^URI hexadecimal escape sequences (%HH) are supported within the path and
  3485 ** query components of a URI. A hexadecimal escape sequence consists of a
  3486 ** percent sign - "%" - followed by exactly two hexadecimal digits 
  3487 ** specifying an octet value. ^Before the path or query components of a
  3488 ** URI filename are interpreted, they are encoded using UTF-8 and all 
  3489 ** hexadecimal escape sequences replaced by a single byte containing the
  3490 ** corresponding octet. If this process generates an invalid UTF-8 encoding,
  3491 ** the results are undefined.
  3492 **
  3493 ** <b>Note to Windows users:</b>  The encoding used for the filename argument
  3494 ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
  3495 ** codepage is currently defined.  Filenames containing international
  3496 ** characters must be converted to UTF-8 prior to passing them into
  3497 ** sqlite3_open() or sqlite3_open_v2().
  3498 **
  3499 ** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
  3500 ** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various
  3501 ** features that require the use of temporary files may fail.
  3502 **
  3503 ** See also: [sqlite3_temp_directory]
  3504 */
  3505 SQLITE_API int sqlite3_open(
  3506   const char *filename,   /* Database filename (UTF-8) */
  3507   sqlite3 **ppDb          /* OUT: SQLite db handle */
  3508 );
  3509 SQLITE_API int sqlite3_open16(
  3510   const void *filename,   /* Database filename (UTF-16) */
  3511   sqlite3 **ppDb          /* OUT: SQLite db handle */
  3512 );
  3513 SQLITE_API int sqlite3_open_v2(
  3514   const char *filename,   /* Database filename (UTF-8) */
  3515   sqlite3 **ppDb,         /* OUT: SQLite db handle */
  3516   int flags,              /* Flags */
  3517   const char *zVfs        /* Name of VFS module to use */
  3518 );
  3519 
  3520 /*
  3521 ** CAPI3REF: Obtain Values For URI Parameters
  3522 **
  3523 ** These are utility routines, useful to VFS implementations, that check
  3524 ** to see if a database file was a URI that contained a specific query 
  3525 ** parameter, and if so obtains the value of that query parameter.
  3526 **
  3527 ** If F is the database filename pointer passed into the xOpen() method of 
  3528 ** a VFS implementation when the flags parameter to xOpen() has one or 
  3529 ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
  3530 ** P is the name of the query parameter, then
  3531 ** sqlite3_uri_parameter(F,P) returns the value of the P
  3532 ** parameter if it exists or a NULL pointer if P does not appear as a 
  3533 ** query parameter on F.  If P is a query parameter of F
  3534 ** has no explicit value, then sqlite3_uri_parameter(F,P) returns
  3535 ** a pointer to an empty string.
  3536 **
  3537 ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
  3538 ** parameter and returns true (1) or false (0) according to the value
  3539 ** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the
  3540 ** value of query parameter P is one of "yes", "true", or "on" in any
  3541 ** case or if the value begins with a non-zero number.  The 
  3542 ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
  3543 ** query parameter P is one of "no", "false", or "off" in any case or
  3544 ** if the value begins with a numeric zero.  If P is not a query
  3545 ** parameter on F or if the value of P is does not match any of the
  3546 ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
  3547 **
  3548 ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
  3549 ** 64-bit signed integer and returns that integer, or D if P does not
  3550 ** exist.  If the value of P is something other than an integer, then
  3551 ** zero is returned.
  3552 ** 
  3553 ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
  3554 ** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and
  3555 ** is not a database file pathname pointer that SQLite passed into the xOpen
  3556 ** VFS method, then the behavior of this routine is undefined and probably
  3557 ** undesirable.
  3558 */
  3559 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
  3560 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
  3561 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
  3562 
  3563 
  3564 /*
  3565 ** CAPI3REF: Error Codes And Messages
  3566 ** METHOD: sqlite3
  3567 **
  3568 ** ^If the most recent sqlite3_* API call associated with 
  3569 ** [database connection] D failed, then the sqlite3_errcode(D) interface
  3570 ** returns the numeric [result code] or [extended result code] for that
  3571 ** API call.
  3572 ** If the most recent API call was successful,
  3573 ** then the return value from sqlite3_errcode() is undefined.
  3574 ** ^The sqlite3_extended_errcode()
  3575 ** interface is the same except that it always returns the 
  3576 ** [extended result code] even when extended result codes are
  3577 ** disabled.
  3578 **
  3579 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
  3580 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
  3581 ** ^(Memory to hold the error message string is managed internally.
  3582 ** The application does not need to worry about freeing the result.
  3583 ** However, the error string might be overwritten or deallocated by
  3584 ** subsequent calls to other SQLite interface functions.)^
  3585 **
  3586 ** ^The sqlite3_errstr() interface returns the English-language text
  3587 ** that describes the [result code], as UTF-8.
  3588 ** ^(Memory to hold the error message string is managed internally
  3589 ** and must not be freed by the application)^.
  3590 **
  3591 ** When the serialized [threading mode] is in use, it might be the
  3592 ** case that a second error occurs on a separate thread in between
  3593 ** the time of the first error and the call to these interfaces.
  3594 ** When that happens, the second error will be reported since these
  3595 ** interfaces always report the most recent result.  To avoid
  3596 ** this, each thread can obtain exclusive use of the [database connection] D
  3597 ** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning
  3598 ** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after
  3599 ** all calls to the interfaces listed here are completed.
  3600 **
  3601 ** If an interface fails with SQLITE_MISUSE, that means the interface
  3602 ** was invoked incorrectly by the application.  In that case, the
  3603 ** error code and message may or may not be set.
  3604 */
  3605 SQLITE_API int sqlite3_errcode(sqlite3 *db);
  3606 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
  3607 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
  3608 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
  3609 SQLITE_API const char *sqlite3_errstr(int);
  3610 
  3611 /*
  3612 ** CAPI3REF: Prepared Statement Object
  3613 ** KEYWORDS: {prepared statement} {prepared statements}
  3614 **
  3615 ** An instance of this object represents a single SQL statement that
  3616 ** has been compiled into binary form and is ready to be evaluated.
  3617 **
  3618 ** Think of each SQL statement as a separate computer program.  The
  3619 ** original SQL text is source code.  A prepared statement object 
  3620 ** is the compiled object code.  All SQL must be converted into a
  3621 ** prepared statement before it can be run.
  3622 **
  3623 ** The life-cycle of a prepared statement object usually goes like this:
  3624 **
  3625 ** <ol>
  3626 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
  3627 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
  3628 **      interfaces.
  3629 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
  3630 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
  3631 **      to step 2.  Do this zero or more times.
  3632 ** <li> Destroy the object using [sqlite3_finalize()].
  3633 ** </ol>
  3634 */
  3635 typedef struct sqlite3_stmt sqlite3_stmt;
  3636 
  3637 /*
  3638 ** CAPI3REF: Run-time Limits
  3639 ** METHOD: sqlite3
  3640 **
  3641 ** ^(This interface allows the size of various constructs to be limited
  3642 ** on a connection by connection basis.  The first parameter is the
  3643 ** [database connection] whose limit is to be set or queried.  The
  3644 ** second parameter is one of the [limit categories] that define a
  3645 ** class of constructs to be size limited.  The third parameter is the
  3646 ** new limit for that construct.)^
  3647 **
  3648 ** ^If the new limit is a negative number, the limit is unchanged.
  3649 ** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a 
  3650 ** [limits | hard upper bound]
  3651 ** set at compile-time by a C preprocessor macro called
  3652 ** [limits | SQLITE_MAX_<i>NAME</i>].
  3653 ** (The "_LIMIT_" in the name is changed to "_MAX_".))^
  3654 ** ^Attempts to increase a limit above its hard upper bound are
  3655 ** silently truncated to the hard upper bound.
  3656 **
  3657 ** ^Regardless of whether or not the limit was changed, the 
  3658 ** [sqlite3_limit()] interface returns the prior value of the limit.
  3659 ** ^Hence, to find the current value of a limit without changing it,
  3660 ** simply invoke this interface with the third parameter set to -1.
  3661 **
  3662 ** Run-time limits are intended for use in applications that manage
  3663 ** both their own internal database and also databases that are controlled
  3664 ** by untrusted external sources.  An example application might be a
  3665 ** web browser that has its own databases for storing history and
  3666 ** separate databases controlled by JavaScript applications downloaded
  3667 ** off the Internet.  The internal databases can be given the
  3668 ** large, default limits.  Databases managed by external sources can
  3669 ** be given much smaller limits designed to prevent a denial of service
  3670 ** attack.  Developers might also want to use the [sqlite3_set_authorizer()]
  3671 ** interface to further control untrusted SQL.  The size of the database
  3672 ** created by an untrusted script can be contained using the
  3673 ** [max_page_count] [PRAGMA].
  3674 **
  3675 ** New run-time limit categories may be added in future releases.
  3676 */
  3677 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
  3678 
  3679 /*
  3680 ** CAPI3REF: Run-Time Limit Categories
  3681 ** KEYWORDS: {limit category} {*limit categories}
  3682 **
  3683 ** These constants define various performance limits
  3684 ** that can be lowered at run-time using [sqlite3_limit()].
  3685 ** The synopsis of the meanings of the various limits is shown below.
  3686 ** Additional information is available at [limits | Limits in SQLite].
  3687 **
  3688 ** <dl>
  3689 ** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>
  3690 ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
  3691 **
  3692 ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
  3693 ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
  3694 **
  3695 ** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>
  3696 ** <dd>The maximum number of columns in a table definition or in the
  3697 ** result set of a [SELECT] or the maximum number of columns in an index
  3698 ** or in an ORDER BY or GROUP BY clause.</dd>)^
  3699 **
  3700 ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
  3701 ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
  3702 **
  3703 ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
  3704 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
  3705 **
  3706 ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
  3707 ** <dd>The maximum number of instructions in a virtual machine program
  3708 ** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or
  3709 ** the equivalent tries to allocate space for more than this many opcodes
  3710 ** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^
  3711 **
  3712 ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
  3713 ** <dd>The maximum number of arguments on a function.</dd>)^
  3714 **
  3715 ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
  3716 ** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
  3717 **
  3718 ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]
  3719 ** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
  3720 ** <dd>The maximum length of the pattern argument to the [LIKE] or
  3721 ** [GLOB] operators.</dd>)^
  3722 **
  3723 ** [[SQLITE_LIMIT_VARIABLE_NUMBER]]
  3724 ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
  3725 ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
  3726 **
  3727 ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
  3728 ** <dd>The maximum depth of recursion for triggers.</dd>)^
  3729 **
  3730 ** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
  3731 ** <dd>The maximum number of auxiliary worker threads that a single
  3732 ** [prepared statement] may start.</dd>)^
  3733 ** </dl>
  3734 */
  3735 #define SQLITE_LIMIT_LENGTH                    0
  3736 #define SQLITE_LIMIT_SQL_LENGTH                1
  3737 #define SQLITE_LIMIT_COLUMN                    2
  3738 #define SQLITE_LIMIT_EXPR_DEPTH                3
  3739 #define SQLITE_LIMIT_COMPOUND_SELECT           4
  3740 #define SQLITE_LIMIT_VDBE_OP                   5
  3741 #define SQLITE_LIMIT_FUNCTION_ARG              6
  3742 #define SQLITE_LIMIT_ATTACHED                  7
  3743 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
  3744 #define SQLITE_LIMIT_VARIABLE_NUMBER           9
  3745 #define SQLITE_LIMIT_TRIGGER_DEPTH            10
  3746 #define SQLITE_LIMIT_WORKER_THREADS           11
  3747 
  3748 
  3749 /*
  3750 ** CAPI3REF: Compiling An SQL Statement
  3751 ** KEYWORDS: {SQL statement compiler}
  3752 ** METHOD: sqlite3
  3753 ** CONSTRUCTOR: sqlite3_stmt
  3754 **
  3755 ** To execute an SQL query, it must first be compiled into a byte-code
  3756 ** program using one of these routines.
  3757 **
  3758 ** The first argument, "db", is a [database connection] obtained from a
  3759 ** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or
  3760 ** [sqlite3_open16()].  The database connection must not have been closed.
  3761 **
  3762 ** The second argument, "zSql", is the statement to be compiled, encoded
  3763 ** as either UTF-8 or UTF-16.  The sqlite3_prepare() and sqlite3_prepare_v2()
  3764 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
  3765 ** use UTF-16.
  3766 **
  3767 ** ^If the nByte argument is negative, then zSql is read up to the
  3768 ** first zero terminator. ^If nByte is positive, then it is the
  3769 ** number of bytes read from zSql.  ^If nByte is zero, then no prepared
  3770 ** statement is generated.
  3771 ** If the caller knows that the supplied string is nul-terminated, then
  3772 ** there is a small performance advantage to passing an nByte parameter that
  3773 ** is the number of bytes in the input string <i>including</i>
  3774 ** the nul-terminator.
  3775 **
  3776 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
  3777 ** past the end of the first SQL statement in zSql.  These routines only
  3778 ** compile the first statement in zSql, so *pzTail is left pointing to
  3779 ** what remains uncompiled.
  3780 **
  3781 ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
  3782 ** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set
  3783 ** to NULL.  ^If the input text contains no SQL (if the input is an empty
  3784 ** string or a comment) then *ppStmt is set to NULL.
  3785 ** The calling procedure is responsible for deleting the compiled
  3786 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
  3787 ** ppStmt may not be NULL.
  3788 **
  3789 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
  3790 ** otherwise an [error code] is returned.
  3791 **
  3792 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
  3793 ** recommended for all new programs. The two older interfaces are retained
  3794 ** for backwards compatibility, but their use is discouraged.
  3795 ** ^In the "v2" interfaces, the prepared statement
  3796 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
  3797 ** original SQL text. This causes the [sqlite3_step()] interface to
  3798 ** behave differently in three ways:
  3799 **
  3800 ** <ol>
  3801 ** <li>
  3802 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
  3803 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
  3804 ** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]
  3805 ** retries will occur before sqlite3_step() gives up and returns an error.
  3806 ** </li>
  3807 **
  3808 ** <li>
  3809 ** ^When an error occurs, [sqlite3_step()] will return one of the detailed
  3810 ** [error codes] or [extended error codes].  ^The legacy behavior was that
  3811 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
  3812 ** and the application would have to make a second call to [sqlite3_reset()]
  3813 ** in order to find the underlying cause of the problem. With the "v2" prepare
  3814 ** interfaces, the underlying reason for the error is returned immediately.
  3815 ** </li>
  3816 **
  3817 ** <li>
  3818 ** ^If the specific value bound to [parameter | host parameter] in the 
  3819 ** WHERE clause might influence the choice of query plan for a statement,
  3820 ** then the statement will be automatically recompiled, as if there had been 
  3821 ** a schema change, on the first  [sqlite3_step()] call following any change
  3822 ** to the [sqlite3_bind_text | bindings] of that [parameter]. 
  3823 ** ^The specific value of WHERE-clause [parameter] might influence the 
  3824 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
  3825 ** or [GLOB] operator or if the parameter is compared to an indexed column
  3826 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
  3827 ** </li>
  3828 ** </ol>
  3829 */
  3830 SQLITE_API int sqlite3_prepare(
  3831   sqlite3 *db,            /* Database handle */
  3832   const char *zSql,       /* SQL statement, UTF-8 encoded */
  3833   int nByte,              /* Maximum length of zSql in bytes. */
  3834   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3835   const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  3836 );
  3837 SQLITE_API int sqlite3_prepare_v2(
  3838   sqlite3 *db,            /* Database handle */
  3839   const char *zSql,       /* SQL statement, UTF-8 encoded */
  3840   int nByte,              /* Maximum length of zSql in bytes. */
  3841   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3842   const char **pzTail     /* OUT: Pointer to unused portion of zSql */
  3843 );
  3844 SQLITE_API int sqlite3_prepare16(
  3845   sqlite3 *db,            /* Database handle */
  3846   const void *zSql,       /* SQL statement, UTF-16 encoded */
  3847   int nByte,              /* Maximum length of zSql in bytes. */
  3848   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3849   const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  3850 );
  3851 SQLITE_API int sqlite3_prepare16_v2(
  3852   sqlite3 *db,            /* Database handle */
  3853   const void *zSql,       /* SQL statement, UTF-16 encoded */
  3854   int nByte,              /* Maximum length of zSql in bytes. */
  3855   sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
  3856   const void **pzTail     /* OUT: Pointer to unused portion of zSql */
  3857 );
  3858 
  3859 /*
  3860 ** CAPI3REF: Retrieving Statement SQL
  3861 ** METHOD: sqlite3_stmt
  3862 **
  3863 ** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
  3864 ** SQL text used to create [prepared statement] P if P was
  3865 ** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
  3866 ** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
  3867 ** string containing the SQL text of prepared statement P with
  3868 ** [bound parameters] expanded.
  3869 **
  3870 ** ^(For example, if a prepared statement is created using the SQL
  3871 ** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
  3872 ** and parameter :xyz is unbound, then sqlite3_sql() will return
  3873 ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
  3874 ** will return "SELECT 2345,NULL".)^
  3875 **
  3876 ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
  3877 ** is available to hold the result, or if the result would exceed the
  3878 ** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
  3879 **
  3880 ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
  3881 ** bound parameter expansions.  ^The [SQLITE_OMIT_TRACE] compile-time
  3882 ** option causes sqlite3_expanded_sql() to always return NULL.
  3883 **
  3884 ** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
  3885 ** automatically freed when the prepared statement is finalized.
  3886 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
  3887 ** is obtained from [sqlite3_malloc()] and must be free by the application
  3888 ** by passing it to [sqlite3_free()].
  3889 */
  3890 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
  3891 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
  3892 
  3893 /*
  3894 ** CAPI3REF: Determine If An SQL Statement Writes The Database
  3895 ** METHOD: sqlite3_stmt
  3896 **
  3897 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
  3898 ** and only if the [prepared statement] X makes no direct changes to
  3899 ** the content of the database file.
  3900 **
  3901 ** Note that [application-defined SQL functions] or
  3902 ** [virtual tables] might change the database indirectly as a side effect.  
  3903 ** ^(For example, if an application defines a function "eval()" that 
  3904 ** calls [sqlite3_exec()], then the following SQL statement would
  3905 ** change the database file through side-effects:
  3906 **
  3907 ** <blockquote><pre>
  3908 **    SELECT eval('DELETE FROM t1') FROM t2;
  3909 ** </pre></blockquote>
  3910 **
  3911 ** But because the [SELECT] statement does not change the database file
  3912 ** directly, sqlite3_stmt_readonly() would still return true.)^
  3913 **
  3914 ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],
  3915 ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,
  3916 ** since the statements themselves do not actually modify the database but
  3917 ** rather they control the timing of when other statements modify the 
  3918 ** database.  ^The [ATTACH] and [DETACH] statements also cause
  3919 ** sqlite3_stmt_readonly() to return true since, while those statements
  3920 ** change the configuration of a database connection, they do not make 
  3921 ** changes to the content of the database files on disk.
  3922 ** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since
  3923 ** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and
  3924 ** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so
  3925 ** sqlite3_stmt_readonly() returns false for those commands.
  3926 */
  3927 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
  3928 
  3929 /*
  3930 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
  3931 ** METHOD: sqlite3_stmt
  3932 **
  3933 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
  3934 ** [prepared statement] S has been stepped at least once using 
  3935 ** [sqlite3_step(S)] but has neither run to completion (returned
  3936 ** [SQLITE_DONE] from [sqlite3_step(S)]) nor
  3937 ** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)
  3938 ** interface returns false if S is a NULL pointer.  If S is not a 
  3939 ** NULL pointer and is not a pointer to a valid [prepared statement]
  3940 ** object, then the behavior is undefined and probably undesirable.
  3941 **
  3942 ** This interface can be used in combination [sqlite3_next_stmt()]
  3943 ** to locate all prepared statements associated with a database 
  3944 ** connection that are in need of being reset.  This can be used,
  3945 ** for example, in diagnostic routines to search for prepared 
  3946 ** statements that are holding a transaction open.
  3947 */
  3948 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
  3949 
  3950 /*
  3951 ** CAPI3REF: Dynamically Typed Value Object
  3952 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
  3953 **
  3954 ** SQLite uses the sqlite3_value object to represent all values
  3955 ** that can be stored in a database table. SQLite uses dynamic typing
  3956 ** for the values it stores.  ^Values stored in sqlite3_value objects
  3957 ** can be integers, floating point values, strings, BLOBs, or NULL.
  3958 **
  3959 ** An sqlite3_value object may be either "protected" or "unprotected".
  3960 ** Some interfaces require a protected sqlite3_value.  Other interfaces
  3961 ** will accept either a protected or an unprotected sqlite3_value.
  3962 ** Every interface that accepts sqlite3_value arguments specifies
  3963 ** whether or not it requires a protected sqlite3_value.  The
  3964 ** [sqlite3_value_dup()] interface can be used to construct a new 
  3965 ** protected sqlite3_value from an unprotected sqlite3_value.
  3966 **
  3967 ** The terms "protected" and "unprotected" refer to whether or not
  3968 ** a mutex is held.  An internal mutex is held for a protected
  3969 ** sqlite3_value object but no mutex is held for an unprotected
  3970 ** sqlite3_value object.  If SQLite is compiled to be single-threaded
  3971 ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
  3972 ** or if SQLite is run in one of reduced mutex modes 
  3973 ** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]
  3974 ** then there is no distinction between protected and unprotected
  3975 ** sqlite3_value objects and they can be used interchangeably.  However,
  3976 ** for maximum code portability it is recommended that applications
  3977 ** still make the distinction between protected and unprotected
  3978 ** sqlite3_value objects even when not strictly required.
  3979 **
  3980 ** ^The sqlite3_value objects that are passed as parameters into the
  3981 ** implementation of [application-defined SQL functions] are protected.
  3982 ** ^The sqlite3_value object returned by
  3983 ** [sqlite3_column_value()] is unprotected.
  3984 ** Unprotected sqlite3_value objects may only be used with
  3985 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
  3986 ** The [sqlite3_value_blob | sqlite3_value_type()] family of
  3987 ** interfaces require protected sqlite3_value objects.
  3988 */
  3989 typedef struct sqlite3_value sqlite3_value;
  3990 
  3991 /*
  3992 ** CAPI3REF: SQL Function Context Object
  3993 **
  3994 ** The context in which an SQL function executes is stored in an
  3995 ** sqlite3_context object.  ^A pointer to an sqlite3_context object
  3996 ** is always first parameter to [application-defined SQL functions].
  3997 ** The application-defined SQL function implementation will pass this
  3998 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
  3999 ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
  4000 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
  4001 ** and/or [sqlite3_set_auxdata()].
  4002 */
  4003 typedef struct sqlite3_context sqlite3_context;
  4004 
  4005 /*
  4006 ** CAPI3REF: Binding Values To Prepared Statements
  4007 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
  4008 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
  4009 ** METHOD: sqlite3_stmt
  4010 **
  4011 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
  4012 ** literals may be replaced by a [parameter] that matches one of following
  4013 ** templates:
  4014 **
  4015 ** <ul>
  4016 ** <li>  ?
  4017 ** <li>  ?NNN
  4018 ** <li>  :VVV
  4019 ** <li>  @VVV
  4020 ** <li>  $VVV
  4021 ** </ul>
  4022 **
  4023 ** In the templates above, NNN represents an integer literal,
  4024 ** and VVV represents an alphanumeric identifier.)^  ^The values of these
  4025 ** parameters (also called "host parameter names" or "SQL parameters")
  4026 ** can be set using the sqlite3_bind_*() routines defined here.
  4027 **
  4028 ** ^The first argument to the sqlite3_bind_*() routines is always
  4029 ** a pointer to the [sqlite3_stmt] object returned from
  4030 ** [sqlite3_prepare_v2()] or its variants.
  4031 **
  4032 ** ^The second argument is the index of the SQL parameter to be set.
  4033 ** ^The leftmost SQL parameter has an index of 1.  ^When the same named
  4034 ** SQL parameter is used more than once, second and subsequent
  4035 ** occurrences have the same index as the first occurrence.
  4036 ** ^The index for named parameters can be looked up using the
  4037 ** [sqlite3_bind_parameter_index()] API if desired.  ^The index
  4038 ** for "?NNN" parameters is the value of NNN.
  4039 ** ^The NNN value must be between 1 and the [sqlite3_limit()]
  4040 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
  4041 **
  4042 ** ^The third argument is the value to bind to the parameter.
  4043 ** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()
  4044 ** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter
  4045 ** is ignored and the end result is the same as sqlite3_bind_null().
  4046 **
  4047 ** ^(In those routines that have a fourth argument, its value is the
  4048 ** number of bytes in the parameter.  To be clear: the value is the
  4049 ** number of <u>bytes</u> in the value, not the number of characters.)^
  4050 ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
  4051 ** is negative, then the length of the string is
  4052 ** the number of bytes up to the first zero terminator.
  4053 ** If the fourth parameter to sqlite3_bind_blob() is negative, then
  4054 ** the behavior is undefined.
  4055 ** If a non-negative fourth parameter is provided to sqlite3_bind_text()
  4056 ** or sqlite3_bind_text16() or sqlite3_bind_text64() then
  4057 ** that parameter must be the byte offset
  4058 ** where the NUL terminator would occur assuming the string were NUL
  4059 ** terminated.  If any NUL characters occur at byte offsets less than 
  4060 ** the value of the fourth parameter then the resulting string value will
  4061 ** contain embedded NULs.  The result of expressions involving strings
  4062 ** with embedded NULs is undefined.
  4063 **
  4064 ** ^The fifth argument to the BLOB and string binding interfaces
  4065 ** is a destructor used to dispose of the BLOB or
  4066 ** string after SQLite has finished with it.  ^The destructor is called
  4067 ** to dispose of the BLOB or string even if the call to bind API fails.
  4068 ** ^If the fifth argument is
  4069 ** the special value [SQLITE_STATIC], then SQLite assumes that the
  4070 ** information is in static, unmanaged space and does not need to be freed.
  4071 ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
  4072 ** SQLite makes its own private copy of the data immediately, before
  4073 ** the sqlite3_bind_*() routine returns.
  4074 **
  4075 ** ^The sixth argument to sqlite3_bind_text64() must be one of
  4076 ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
  4077 ** to specify the encoding of the text in the third parameter.  If
  4078 ** the sixth argument to sqlite3_bind_text64() is not one of the
  4079 ** allowed values shown above, or if the text encoding is different
  4080 ** from the encoding specified by the sixth parameter, then the behavior
  4081 ** is undefined.
  4082 **
  4083 ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
  4084 ** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  4085 ** (just an integer to hold its size) while it is being processed.
  4086 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
  4087 ** content is later written using
  4088 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
  4089 ** ^A negative value for the zeroblob results in a zero-length BLOB.
  4090 **
  4091 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
  4092 ** for the [prepared statement] or with a prepared statement for which
  4093 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
  4094 ** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()
  4095 ** routine is passed a [prepared statement] that has been finalized, the
  4096 ** result is undefined and probably harmful.
  4097 **
  4098 ** ^Bindings are not cleared by the [sqlite3_reset()] routine.
  4099 ** ^Unbound parameters are interpreted as NULL.
  4100 **
  4101 ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
  4102 ** [error code] if anything goes wrong.
  4103 ** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
  4104 ** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
  4105 ** [SQLITE_MAX_LENGTH].
  4106 ** ^[SQLITE_RANGE] is returned if the parameter
  4107 ** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.
  4108 **
  4109 ** See also: [sqlite3_bind_parameter_count()],
  4110 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
  4111 */
  4112 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
  4113 SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
  4114                         void(*)(void*));
  4115 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
  4116 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
  4117 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  4118 SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
  4119 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
  4120 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  4121 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
  4122                          void(*)(void*), unsigned char encoding);
  4123 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  4124 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  4125 SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
  4126 
  4127 /*
  4128 ** CAPI3REF: Number Of SQL Parameters
  4129 ** METHOD: sqlite3_stmt
  4130 **
  4131 ** ^This routine can be used to find the number of [SQL parameters]
  4132 ** in a [prepared statement].  SQL parameters are tokens of the
  4133 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
  4134 ** placeholders for values that are [sqlite3_bind_blob | bound]
  4135 ** to the parameters at a later time.
  4136 **
  4137 ** ^(This routine actually returns the index of the largest (rightmost)
  4138 ** parameter. For all forms except ?NNN, this will correspond to the
  4139 ** number of unique parameters.  If parameters of the ?NNN form are used,
  4140 ** there may be gaps in the list.)^
  4141 **
  4142 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  4143 ** [sqlite3_bind_parameter_name()], and
  4144 ** [sqlite3_bind_parameter_index()].
  4145 */
  4146 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
  4147 
  4148 /*
  4149 ** CAPI3REF: Name Of A Host Parameter
  4150 ** METHOD: sqlite3_stmt
  4151 **
  4152 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
  4153 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
  4154 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
  4155 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
  4156 ** respectively.
  4157 ** In other words, the initial ":" or "$" or "@" or "?"
  4158 ** is included as part of the name.)^
  4159 ** ^Parameters of the form "?" without a following integer have no name
  4160 ** and are referred to as "nameless" or "anonymous parameters".
  4161 **
  4162 ** ^The first host parameter has an index of 1, not 0.
  4163 **
  4164 ** ^If the value N is out of range or if the N-th parameter is
  4165 ** nameless, then NULL is returned.  ^The returned string is
  4166 ** always in UTF-8 encoding even if the named parameter was
  4167 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
  4168 ** [sqlite3_prepare16_v2()].
  4169 **
  4170 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  4171 ** [sqlite3_bind_parameter_count()], and
  4172 ** [sqlite3_bind_parameter_index()].
  4173 */
  4174 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
  4175 
  4176 /*
  4177 ** CAPI3REF: Index Of A Parameter With A Given Name
  4178 ** METHOD: sqlite3_stmt
  4179 **
  4180 ** ^Return the index of an SQL parameter given its name.  ^The
  4181 ** index value returned is suitable for use as the second
  4182 ** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero
  4183 ** is returned if no matching parameter is found.  ^The parameter
  4184 ** name must be given in UTF-8 even if the original statement
  4185 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
  4186 **
  4187 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
  4188 ** [sqlite3_bind_parameter_count()], and
  4189 ** [sqlite3_bind_parameter_name()].
  4190 */
  4191 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
  4192 
  4193 /*
  4194 ** CAPI3REF: Reset All Bindings On A Prepared Statement
  4195 ** METHOD: sqlite3_stmt
  4196 **
  4197 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
  4198 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
  4199 ** ^Use this routine to reset all host parameters to NULL.
  4200 */
  4201 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
  4202 
  4203 /*
  4204 ** CAPI3REF: Number Of Columns In A Result Set
  4205 ** METHOD: sqlite3_stmt
  4206 **
  4207 ** ^Return the number of columns in the result set returned by the
  4208 ** [prepared statement]. ^If this routine returns 0, that means the 
  4209 ** [prepared statement] returns no data (for example an [UPDATE]).
  4210 ** ^However, just because this routine returns a positive number does not
  4211 ** mean that one or more rows of data will be returned.  ^A SELECT statement
  4212 ** will always have a positive sqlite3_column_count() but depending on the
  4213 ** WHERE clause constraints and the table content, it might return no rows.
  4214 **
  4215 ** See also: [sqlite3_data_count()]
  4216 */
  4217 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
  4218 
  4219 /*
  4220 ** CAPI3REF: Column Names In A Result Set
  4221 ** METHOD: sqlite3_stmt
  4222 **
  4223 ** ^These routines return the name assigned to a particular column
  4224 ** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()
  4225 ** interface returns a pointer to a zero-terminated UTF-8 string
  4226 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
  4227 ** UTF-16 string.  ^The first parameter is the [prepared statement]
  4228 ** that implements the [SELECT] statement. ^The second parameter is the
  4229 ** column number.  ^The leftmost column is number 0.
  4230 **
  4231 ** ^The returned string pointer is valid until either the [prepared statement]
  4232 ** is destroyed by [sqlite3_finalize()] or until the statement is automatically
  4233 ** reprepared by the first call to [sqlite3_step()] for a particular run
  4234 ** or until the next call to
  4235 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
  4236 **
  4237 ** ^If sqlite3_malloc() fails during the processing of either routine
  4238 ** (for example during a conversion from UTF-8 to UTF-16) then a
  4239 ** NULL pointer is returned.
  4240 **
  4241 ** ^The name of a result column is the value of the "AS" clause for
  4242 ** that column, if there is an AS clause.  If there is no AS clause
  4243 ** then the name of the column is unspecified and may change from
  4244 ** one release of SQLite to the next.
  4245 */
  4246 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
  4247 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
  4248 
  4249 /*
  4250 ** CAPI3REF: Source Of Data In A Query Result
  4251 ** METHOD: sqlite3_stmt
  4252 **
  4253 ** ^These routines provide a means to determine the database, table, and
  4254 ** table column that is the origin of a particular result column in
  4255 ** [SELECT] statement.
  4256 ** ^The name of the database or table or column can be returned as
  4257 ** either a UTF-8 or UTF-16 string.  ^The _database_ routines return
  4258 ** the database name, the _table_ routines return the table name, and
  4259 ** the origin_ routines return the column name.
  4260 ** ^The returned string is valid until the [prepared statement] is destroyed
  4261 ** using [sqlite3_finalize()] or until the statement is automatically
  4262 ** reprepared by the first call to [sqlite3_step()] for a particular run
  4263 ** or until the same information is requested
  4264 ** again in a different encoding.
  4265 **
  4266 ** ^The names returned are the original un-aliased names of the
  4267 ** database, table, and column.
  4268 **
  4269 ** ^The first argument to these interfaces is a [prepared statement].
  4270 ** ^These functions return information about the Nth result column returned by
  4271 ** the statement, where N is the second function argument.
  4272 ** ^The left-most column is column 0 for these routines.
  4273 **
  4274 ** ^If the Nth column returned by the statement is an expression or
  4275 ** subquery and is not a column value, then all of these functions return
  4276 ** NULL.  ^These routine might also return NULL if a memory allocation error
  4277 ** occurs.  ^Otherwise, they return the name of the attached database, table,
  4278 ** or column that query result column was extracted from.
  4279 **
  4280 ** ^As with all other SQLite APIs, those whose names end with "16" return
  4281 ** UTF-16 encoded strings and the other functions return UTF-8.
  4282 **
  4283 ** ^These APIs are only available if the library was compiled with the
  4284 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
  4285 **
  4286 ** If two or more threads call one or more of these routines against the same
  4287 ** prepared statement and column at the same time then the results are
  4288 ** undefined.
  4289 **
  4290 ** If two or more threads call one or more
  4291 ** [sqlite3_column_database_name | column metadata interfaces]
  4292 ** for the same [prepared statement] and result column
  4293 ** at the same time then the results are undefined.
  4294 */
  4295 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
  4296 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
  4297 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
  4298 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
  4299 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
  4300 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
  4301 
  4302 /*
  4303 ** CAPI3REF: Declared Datatype Of A Query Result
  4304 ** METHOD: sqlite3_stmt
  4305 **
  4306 ** ^(The first parameter is a [prepared statement].
  4307 ** If this statement is a [SELECT] statement and the Nth column of the
  4308 ** returned result set of that [SELECT] is a table column (not an
  4309 ** expression or subquery) then the declared type of the table
  4310 ** column is returned.)^  ^If the Nth column of the result set is an
  4311 ** expression or subquery, then a NULL pointer is returned.
  4312 ** ^The returned string is always UTF-8 encoded.
  4313 **
  4314 ** ^(For example, given the database schema:
  4315 **
  4316 ** CREATE TABLE t1(c1 VARIANT);
  4317 **
  4318 ** and the following statement to be compiled:
  4319 **
  4320 ** SELECT c1 + 1, c1 FROM t1;
  4321 **
  4322 ** this routine would return the string "VARIANT" for the second result
  4323 ** column (i==1), and a NULL pointer for the first result column (i==0).)^
  4324 **
  4325 ** ^SQLite uses dynamic run-time typing.  ^So just because a column
  4326 ** is declared to contain a particular type does not mean that the
  4327 ** data stored in that column is of the declared type.  SQLite is
  4328 ** strongly typed, but the typing is dynamic not static.  ^Type
  4329 ** is associated with individual values, not with the containers
  4330 ** used to hold those values.
  4331 */
  4332 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
  4333 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
  4334 
  4335 /*
  4336 ** CAPI3REF: Evaluate An SQL Statement
  4337 ** METHOD: sqlite3_stmt
  4338 **
  4339 ** After a [prepared statement] has been prepared using either
  4340 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
  4341 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
  4342 ** must be called one or more times to evaluate the statement.
  4343 **
  4344 ** The details of the behavior of the sqlite3_step() interface depend
  4345 ** on whether the statement was prepared using the newer "v2" interface
  4346 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
  4347 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the
  4348 ** new "v2" interface is recommended for new applications but the legacy
  4349 ** interface will continue to be supported.
  4350 **
  4351 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
  4352 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
  4353 ** ^With the "v2" interface, any of the other [result codes] or
  4354 ** [extended result codes] might be returned as well.
  4355 **
  4356 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
  4357 ** database locks it needs to do its job.  ^If the statement is a [COMMIT]
  4358 ** or occurs outside of an explicit transaction, then you can retry the
  4359 ** statement.  If the statement is not a [COMMIT] and occurs within an
  4360 ** explicit transaction then you should rollback the transaction before
  4361 ** continuing.
  4362 **
  4363 ** ^[SQLITE_DONE] means that the statement has finished executing
  4364 ** successfully.  sqlite3_step() should not be called again on this virtual
  4365 ** machine without first calling [sqlite3_reset()] to reset the virtual
  4366 ** machine back to its initial state.
  4367 **
  4368 ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
  4369 ** is returned each time a new row of data is ready for processing by the
  4370 ** caller. The values may be accessed using the [column access functions].
  4371 ** sqlite3_step() is called again to retrieve the next row of data.
  4372 **
  4373 ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
  4374 ** violation) has occurred.  sqlite3_step() should not be called again on
  4375 ** the VM. More information may be found by calling [sqlite3_errmsg()].
  4376 ** ^With the legacy interface, a more specific error code (for example,
  4377 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
  4378 ** can be obtained by calling [sqlite3_reset()] on the
  4379 ** [prepared statement].  ^In the "v2" interface,
  4380 ** the more specific error code is returned directly by sqlite3_step().
  4381 **
  4382 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
  4383 ** Perhaps it was called on a [prepared statement] that has
  4384 ** already been [sqlite3_finalize | finalized] or on one that had
  4385 ** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could
  4386 ** be the case that the same database connection is being used by two or
  4387 ** more threads at the same moment in time.
  4388 **
  4389 ** For all versions of SQLite up to and including 3.6.23.1, a call to
  4390 ** [sqlite3_reset()] was required after sqlite3_step() returned anything
  4391 ** other than [SQLITE_ROW] before any subsequent invocation of
  4392 ** sqlite3_step().  Failure to reset the prepared statement using 
  4393 ** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from
  4394 ** sqlite3_step().  But after [version 3.6.23.1] ([dateof:3.6.23.1],
  4395 ** sqlite3_step() began
  4396 ** calling [sqlite3_reset()] automatically in this circumstance rather
  4397 ** than returning [SQLITE_MISUSE].  This is not considered a compatibility
  4398 ** break because any application that ever receives an SQLITE_MISUSE error
  4399 ** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option
  4400 ** can be used to restore the legacy behavior.
  4401 **
  4402 ** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()
  4403 ** API always returns a generic error code, [SQLITE_ERROR], following any
  4404 ** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call
  4405 ** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the
  4406 ** specific [error codes] that better describes the error.
  4407 ** We admit that this is a goofy design.  The problem has been fixed
  4408 ** with the "v2" interface.  If you prepare all of your SQL statements
  4409 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
  4410 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
  4411 ** then the more specific [error codes] are returned directly
  4412 ** by sqlite3_step().  The use of the "v2" interface is recommended.
  4413 */
  4414 SQLITE_API int sqlite3_step(sqlite3_stmt*);
  4415 
  4416 /*
  4417 ** CAPI3REF: Number of columns in a result set
  4418 ** METHOD: sqlite3_stmt
  4419 **
  4420 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  4421 ** current row of the result set of [prepared statement] P.
  4422 ** ^If prepared statement P does not have results ready to return
  4423 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
  4424 ** interfaces) then sqlite3_data_count(P) returns 0.
  4425 ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
  4426 ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
  4427 ** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)
  4428 ** will return non-zero if previous call to [sqlite3_step](P) returned
  4429 ** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]
  4430 ** where it always returns zero since each step of that multi-step
  4431 ** pragma returns 0 columns of data.
  4432 **
  4433 ** See also: [sqlite3_column_count()]
  4434 */
  4435 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
  4436 
  4437 /*
  4438 ** CAPI3REF: Fundamental Datatypes
  4439 ** KEYWORDS: SQLITE_TEXT
  4440 **
  4441 ** ^(Every value in SQLite has one of five fundamental datatypes:
  4442 **
  4443 ** <ul>
  4444 ** <li> 64-bit signed integer
  4445 ** <li> 64-bit IEEE floating point number
  4446 ** <li> string
  4447 ** <li> BLOB
  4448 ** <li> NULL
  4449 ** </ul>)^
  4450 **
  4451 ** These constants are codes for each of those types.
  4452 **
  4453 ** Note that the SQLITE_TEXT constant was also used in SQLite version 2
  4454 ** for a completely different meaning.  Software that links against both
  4455 ** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not
  4456 ** SQLITE_TEXT.
  4457 */
  4458 #define SQLITE_INTEGER  1
  4459 #define SQLITE_FLOAT    2
  4460 #define SQLITE_BLOB     4
  4461 #define SQLITE_NULL     5
  4462 #ifdef SQLITE_TEXT
  4463 # undef SQLITE_TEXT
  4464 #else
  4465 # define SQLITE_TEXT     3
  4466 #endif
  4467 #define SQLITE3_TEXT     3
  4468 
  4469 /*
  4470 ** CAPI3REF: Result Values From A Query
  4471 ** KEYWORDS: {column access functions}
  4472 ** METHOD: sqlite3_stmt
  4473 **
  4474 ** ^These routines return information about a single column of the current
  4475 ** result row of a query.  ^In every case the first argument is a pointer
  4476 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
  4477 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
  4478 ** and the second argument is the index of the column for which information
  4479 ** should be returned. ^The leftmost column of the result set has the index 0.
  4480 ** ^The number of columns in the result can be determined using
  4481 ** [sqlite3_column_count()].
  4482 **
  4483 ** If the SQL statement does not currently point to a valid row, or if the
  4484 ** column index is out of range, the result is undefined.
  4485 ** These routines may only be called when the most recent call to
  4486 ** [sqlite3_step()] has returned [SQLITE_ROW] and neither
  4487 ** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.
  4488 ** If any of these routines are called after [sqlite3_reset()] or
  4489 ** [sqlite3_finalize()] or after [sqlite3_step()] has returned
  4490 ** something other than [SQLITE_ROW], the results are undefined.
  4491 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
  4492 ** are called from a different thread while any of these routines
  4493 ** are pending, then the results are undefined.
  4494 **
  4495 ** ^The sqlite3_column_type() routine returns the
  4496 ** [SQLITE_INTEGER | datatype code] for the initial data type
  4497 ** of the result column.  ^The returned value is one of [SQLITE_INTEGER],
  4498 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].  The value
  4499 ** returned by sqlite3_column_type() is only meaningful if no type
  4500 ** conversions have occurred as described below.  After a type conversion,
  4501 ** the value returned by sqlite3_column_type() is undefined.  Future
  4502 ** versions of SQLite may change the behavior of sqlite3_column_type()
  4503 ** following a type conversion.
  4504 **
  4505 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
  4506 ** routine returns the number of bytes in that BLOB or string.
  4507 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
  4508 ** the string to UTF-8 and then returns the number of bytes.
  4509 ** ^If the result is a numeric value then sqlite3_column_bytes() uses
  4510 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
  4511 ** the number of bytes in that string.
  4512 ** ^If the result is NULL, then sqlite3_column_bytes() returns zero.
  4513 **
  4514 ** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()
  4515 ** routine returns the number of bytes in that BLOB or string.
  4516 ** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts
  4517 ** the string to UTF-16 and then returns the number of bytes.
  4518 ** ^If the result is a numeric value then sqlite3_column_bytes16() uses
  4519 ** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns
  4520 ** the number of bytes in that string.
  4521 ** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.
  4522 **
  4523 ** ^The values returned by [sqlite3_column_bytes()] and 
  4524 ** [sqlite3_column_bytes16()] do not include the zero terminators at the end
  4525 ** of the string.  ^For clarity: the values returned by
  4526 ** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of
  4527 ** bytes in the string, not the number of characters.
  4528 **
  4529 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
  4530 ** even empty strings, are always zero-terminated.  ^The return
  4531 ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
  4532 **
  4533 ** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
  4534 ** [unprotected sqlite3_value] object.  In a multithreaded environment,
  4535 ** an unprotected sqlite3_value object may only be used safely with
  4536 ** [sqlite3_bind_value()] and [sqlite3_result_value()].
  4537 ** If the [unprotected sqlite3_value] object returned by
  4538 ** [sqlite3_column_value()] is used in any other way, including calls
  4539 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
  4540 ** or [sqlite3_value_bytes()], the behavior is not threadsafe.
  4541 **
  4542 ** These routines attempt to convert the value where appropriate.  ^For
  4543 ** example, if the internal representation is FLOAT and a text result
  4544 ** is requested, [sqlite3_snprintf()] is used internally to perform the
  4545 ** conversion automatically.  ^(The following table details the conversions
  4546 ** that are applied:
  4547 **
  4548 ** <blockquote>
  4549 ** <table border="1">
  4550 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion
  4551 **
  4552 ** <tr><td>  NULL    <td> INTEGER   <td> Result is 0
  4553 ** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0
  4554 ** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer
  4555 ** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer
  4556 ** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float
  4557 ** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer
  4558 ** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT
  4559 ** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER
  4560 ** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float
  4561 ** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB
  4562 ** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER
  4563 ** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL
  4564 ** <tr><td>  TEXT    <td>   BLOB    <td> No change
  4565 ** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER
  4566 ** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL
  4567 ** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed
  4568 ** </table>
  4569 ** </blockquote>)^
  4570 **
  4571 ** Note that when type conversions occur, pointers returned by prior
  4572 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
  4573 ** sqlite3_column_text16() may be invalidated.
  4574 ** Type conversions and pointer invalidations might occur
  4575 ** in the following cases:
  4576 **
  4577 ** <ul>
  4578 ** <li> The initial content is a BLOB and sqlite3_column_text() or
  4579 **      sqlite3_column_text16() is called.  A zero-terminator might
  4580 **      need to be added to the string.</li>
  4581 ** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or
  4582 **      sqlite3_column_text16() is called.  The content must be converted
  4583 **      to UTF-16.</li>
  4584 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
  4585 **      sqlite3_column_text() is called.  The content must be converted
  4586 **      to UTF-8.</li>
  4587 ** </ul>
  4588 **
  4589 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
  4590 ** not invalidate a prior pointer, though of course the content of the buffer
  4591 ** that the prior pointer references will have been modified.  Other kinds
  4592 ** of conversion are done in place when it is possible, but sometimes they
  4593 ** are not possible and in those cases prior pointers are invalidated.
  4594 **
  4595 ** The safest policy is to invoke these routines
  4596 ** in one of the following ways:
  4597 **
  4598 ** <ul>
  4599 **  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
  4600 **  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
  4601 **  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
  4602 ** </ul>
  4603 **
  4604 ** In other words, you should call sqlite3_column_text(),
  4605 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
  4606 ** into the desired format, then invoke sqlite3_column_bytes() or
  4607 ** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls
  4608 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
  4609 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
  4610 ** with calls to sqlite3_column_bytes().
  4611 **
  4612 ** ^The pointers returned are valid until a type conversion occurs as
  4613 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  4614 ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  4615 ** and BLOBs is freed automatically.  Do <em>not</em> pass the pointers returned
  4616 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  4617 ** [sqlite3_free()].
  4618 **
  4619 ** ^(If a memory allocation error occurs during the evaluation of any
  4620 ** of these routines, a default value is returned.  The default value
  4621 ** is either the integer 0, the floating point number 0.0, or a NULL
  4622 ** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  4623 ** [SQLITE_NOMEM].)^
  4624 */
  4625 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  4626 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
  4627 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
  4628 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  4629 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  4630 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  4631 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  4632 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
  4633 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
  4634 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
  4635 
  4636 /*
  4637 ** CAPI3REF: Destroy A Prepared Statement Object
  4638 ** DESTRUCTOR: sqlite3_stmt
  4639 **
  4640 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
  4641 ** ^If the most recent evaluation of the statement encountered no errors
  4642 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
  4643 ** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then
  4644 ** sqlite3_finalize(S) returns the appropriate [error code] or
  4645 ** [extended error code].
  4646 **
  4647 ** ^The sqlite3_finalize(S) routine can be called at any point during
  4648 ** the life cycle of [prepared statement] S:
  4649 ** before statement S is ever evaluated, after
  4650 ** one or more calls to [sqlite3_reset()], or after any call
  4651 ** to [sqlite3_step()] regardless of whether or not the statement has
  4652 ** completed execution.
  4653 **
  4654 ** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.
  4655 **
  4656 ** The application must finalize every [prepared statement] in order to avoid
  4657 ** resource leaks.  It is a grievous error for the application to try to use
  4658 ** a prepared statement after it has been finalized.  Any use of a prepared
  4659 ** statement after it has been finalized can result in undefined and
  4660 ** undesirable behavior such as segfaults and heap corruption.
  4661 */
  4662 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
  4663 
  4664 /*
  4665 ** CAPI3REF: Reset A Prepared Statement Object
  4666 ** METHOD: sqlite3_stmt
  4667 **
  4668 ** The sqlite3_reset() function is called to reset a [prepared statement]
  4669 ** object back to its initial state, ready to be re-executed.
  4670 ** ^Any SQL statement variables that had values bound to them using
  4671 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
  4672 ** Use [sqlite3_clear_bindings()] to reset the bindings.
  4673 **
  4674 ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
  4675 ** back to the beginning of its program.
  4676 **
  4677 ** ^If the most recent call to [sqlite3_step(S)] for the
  4678 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
  4679 ** or if [sqlite3_step(S)] has never before been called on S,
  4680 ** then [sqlite3_reset(S)] returns [SQLITE_OK].
  4681 **
  4682 ** ^If the most recent call to [sqlite3_step(S)] for the
  4683 ** [prepared statement] S indicated an error, then
  4684 ** [sqlite3_reset(S)] returns an appropriate [error code].
  4685 **
  4686 ** ^The [sqlite3_reset(S)] interface does not change the values
  4687 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
  4688 */
  4689 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
  4690 
  4691 /*
  4692 ** CAPI3REF: Create Or Redefine SQL Functions
  4693 ** KEYWORDS: {function creation routines}
  4694 ** KEYWORDS: {application-defined SQL function}
  4695 ** KEYWORDS: {application-defined SQL functions}
  4696 ** METHOD: sqlite3
  4697 **
  4698 ** ^These functions (collectively known as "function creation routines")
  4699 ** are used to add SQL functions or aggregates or to redefine the behavior
  4700 ** of existing SQL functions or aggregates.  The only differences between
  4701 ** these routines are the text encoding expected for
  4702 ** the second parameter (the name of the function being created)
  4703 ** and the presence or absence of a destructor callback for
  4704 ** the application data pointer.
  4705 **
  4706 ** ^The first parameter is the [database connection] to which the SQL
  4707 ** function is to be added.  ^If an application uses more than one database
  4708 ** connection then application-defined SQL functions must be added
  4709 ** to each database connection separately.
  4710 **
  4711 ** ^The second parameter is the name of the SQL function to be created or
  4712 ** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8
  4713 ** representation, exclusive of the zero-terminator.  ^Note that the name
  4714 ** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  
  4715 ** ^Any attempt to create a function with a longer name
  4716 ** will result in [SQLITE_MISUSE] being returned.
  4717 **
  4718 ** ^The third parameter (nArg)
  4719 ** is the number of arguments that the SQL function or
  4720 ** aggregate takes. ^If this parameter is -1, then the SQL function or
  4721 ** aggregate may take any number of arguments between 0 and the limit
  4722 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third
  4723 ** parameter is less than -1 or greater than 127 then the behavior is
  4724 ** undefined.
  4725 **
  4726 ** ^The fourth parameter, eTextRep, specifies what
  4727 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
  4728 ** its parameters.  The application should set this parameter to
  4729 ** [SQLITE_UTF16LE] if the function implementation invokes 
  4730 ** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the
  4731 ** implementation invokes [sqlite3_value_text16be()] on an input, or
  4732 ** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]
  4733 ** otherwise.  ^The same SQL function may be registered multiple times using
  4734 ** different preferred text encodings, with different implementations for
  4735 ** each encoding.
  4736 ** ^When multiple implementations of the same function are available, SQLite
  4737 ** will pick the one that involves the least amount of data conversion.
  4738 **
  4739 ** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]
  4740 ** to signal that the function will always return the same result given
  4741 ** the same inputs within a single SQL statement.  Most SQL functions are
  4742 ** deterministic.  The built-in [random()] SQL function is an example of a
  4743 ** function that is not deterministic.  The SQLite query planner is able to
  4744 ** perform additional optimizations on deterministic functions, so use
  4745 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
  4746 **
  4747 ** ^(The fifth parameter is an arbitrary pointer.  The implementation of the
  4748 ** function can gain access to this pointer using [sqlite3_user_data()].)^
  4749 **
  4750 ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
  4751 ** pointers to C-language functions that implement the SQL function or
  4752 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
  4753 ** callback only; NULL pointers must be passed as the xStep and xFinal
  4754 ** parameters. ^An aggregate SQL function requires an implementation of xStep
  4755 ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
  4756 ** SQL function or aggregate, pass NULL pointers for all three function
  4757 ** callbacks.
  4758 **
  4759 ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
  4760 ** then it is destructor for the application data pointer. 
  4761 ** The destructor is invoked when the function is deleted, either by being
  4762 ** overloaded or when the database connection closes.)^
  4763 ** ^The destructor is also invoked if the call to
  4764 ** sqlite3_create_function_v2() fails.
  4765 ** ^When the destructor callback of the tenth parameter is invoked, it
  4766 ** is passed a single argument which is a copy of the application data 
  4767 ** pointer which was the fifth parameter to sqlite3_create_function_v2().
  4768 **
  4769 ** ^It is permitted to register multiple implementations of the same
  4770 ** functions with the same name but with either differing numbers of
  4771 ** arguments or differing preferred text encodings.  ^SQLite will use
  4772 ** the implementation that most closely matches the way in which the
  4773 ** SQL function is used.  ^A function implementation with a non-negative
  4774 ** nArg parameter is a better match than a function implementation with
  4775 ** a negative nArg.  ^A function where the preferred text encoding
  4776 ** matches the database encoding is a better
  4777 ** match than a function where the encoding is different.  
  4778 ** ^A function where the encoding difference is between UTF16le and UTF16be
  4779 ** is a closer match than a function where the encoding difference is
  4780 ** between UTF8 and UTF16.
  4781 **
  4782 ** ^Built-in functions may be overloaded by new application-defined functions.
  4783 **
  4784 ** ^An application-defined function is permitted to call other
  4785 ** SQLite interfaces.  However, such calls must not
  4786 ** close the database connection nor finalize or reset the prepared
  4787 ** statement in which the function is running.
  4788 */
  4789 SQLITE_API int sqlite3_create_function(
  4790   sqlite3 *db,
  4791   const char *zFunctionName,
  4792   int nArg,
  4793   int eTextRep,
  4794   void *pApp,
  4795   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4796   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4797   void (*xFinal)(sqlite3_context*)
  4798 );
  4799 SQLITE_API int sqlite3_create_function16(
  4800   sqlite3 *db,
  4801   const void *zFunctionName,
  4802   int nArg,
  4803   int eTextRep,
  4804   void *pApp,
  4805   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4806   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4807   void (*xFinal)(sqlite3_context*)
  4808 );
  4809 SQLITE_API int sqlite3_create_function_v2(
  4810   sqlite3 *db,
  4811   const char *zFunctionName,
  4812   int nArg,
  4813   int eTextRep,
  4814   void *pApp,
  4815   void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4816   void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4817   void (*xFinal)(sqlite3_context*),
  4818   void(*xDestroy)(void*)
  4819 );
  4820 
  4821 /*
  4822 ** CAPI3REF: Text Encodings
  4823 **
  4824 ** These constant define integer codes that represent the various
  4825 ** text encodings supported by SQLite.
  4826 */
  4827 #define SQLITE_UTF8           1    /* IMP: R-37514-35566 */
  4828 #define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */
  4829 #define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */
  4830 #define SQLITE_UTF16          4    /* Use native byte order */
  4831 #define SQLITE_ANY            5    /* Deprecated */
  4832 #define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
  4833 
  4834 /*
  4835 ** CAPI3REF: Function Flags
  4836 **
  4837 ** These constants may be ORed together with the 
  4838 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
  4839 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
  4840 ** [sqlite3_create_function_v2()].
  4841 */
  4842 #define SQLITE_DETERMINISTIC    0x800
  4843 
  4844 /*
  4845 ** CAPI3REF: Deprecated Functions
  4846 ** DEPRECATED
  4847 **
  4848 ** These functions are [deprecated].  In order to maintain
  4849 ** backwards compatibility with older code, these functions continue 
  4850 ** to be supported.  However, new applications should avoid
  4851 ** the use of these functions.  To encourage programmers to avoid
  4852 ** these functions, we will not explain what they do.
  4853 */
  4854 #ifndef SQLITE_OMIT_DEPRECATED
  4855 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
  4856 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
  4857 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
  4858 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
  4859 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
  4860 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
  4861                       void*,sqlite3_int64);
  4862 #endif
  4863 
  4864 /*
  4865 ** CAPI3REF: Obtaining SQL Values
  4866 ** METHOD: sqlite3_value
  4867 **
  4868 ** The C-language implementation of SQL functions and aggregates uses
  4869 ** this set of interface routines to access the parameter values on
  4870 ** the function or aggregate.  
  4871 **
  4872 ** The xFunc (for scalar functions) or xStep (for aggregates) parameters
  4873 ** to [sqlite3_create_function()] and [sqlite3_create_function16()]
  4874 ** define callbacks that implement the SQL functions and aggregates.
  4875 ** The 3rd parameter to these callbacks is an array of pointers to
  4876 ** [protected sqlite3_value] objects.  There is one [sqlite3_value] object for
  4877 ** each parameter to the SQL function.  These routines are used to
  4878 ** extract values from the [sqlite3_value] objects.
  4879 **
  4880 ** These routines work only with [protected sqlite3_value] objects.
  4881 ** Any attempt to use these routines on an [unprotected sqlite3_value]
  4882 ** object results in undefined behavior.
  4883 **
  4884 ** ^These routines work just like the corresponding [column access functions]
  4885 ** except that these routines take a single [protected sqlite3_value] object
  4886 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  4887 **
  4888 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  4889 ** in the native byte-order of the host machine.  ^The
  4890 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
  4891 ** extract UTF-16 strings as big-endian and little-endian respectively.
  4892 **
  4893 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
  4894 ** numeric affinity to the value.  This means that an attempt is
  4895 ** made to convert the value to an integer or floating point.  If
  4896 ** such a conversion is possible without loss of information (in other
  4897 ** words, if the value is a string that looks like a number)
  4898 ** then the conversion is performed.  Otherwise no conversion occurs.
  4899 ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
  4900 **
  4901 ** Please pay particular attention to the fact that the pointer returned
  4902 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
  4903 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
  4904 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
  4905 ** or [sqlite3_value_text16()].
  4906 **
  4907 ** These routines must be called from the same thread as
  4908 ** the SQL function that supplied the [sqlite3_value*] parameters.
  4909 */
  4910 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  4911 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
  4912 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
  4913 SQLITE_API double sqlite3_value_double(sqlite3_value*);
  4914 SQLITE_API int sqlite3_value_int(sqlite3_value*);
  4915 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  4916 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
  4917 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
  4918 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
  4919 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
  4920 SQLITE_API int sqlite3_value_type(sqlite3_value*);
  4921 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
  4922 
  4923 /*
  4924 ** CAPI3REF: Finding The Subtype Of SQL Values
  4925 ** METHOD: sqlite3_value
  4926 **
  4927 ** The sqlite3_value_subtype(V) function returns the subtype for
  4928 ** an [application-defined SQL function] argument V.  The subtype
  4929 ** information can be used to pass a limited amount of context from
  4930 ** one SQL function to another.  Use the [sqlite3_result_subtype()]
  4931 ** routine to set the subtype for the return value of an SQL function.
  4932 **
  4933 ** SQLite makes no use of subtype itself.  It merely passes the subtype
  4934 ** from the result of one [application-defined SQL function] into the
  4935 ** input of another.
  4936 */
  4937 SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
  4938 
  4939 /*
  4940 ** CAPI3REF: Copy And Free SQL Values
  4941 ** METHOD: sqlite3_value
  4942 **
  4943 ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]
  4944 ** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned
  4945 ** is a [protected sqlite3_value] object even if the input is not.
  4946 ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a
  4947 ** memory allocation fails.
  4948 **
  4949 ** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object
  4950 ** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer
  4951 ** then sqlite3_value_free(V) is a harmless no-op.
  4952 */
  4953 SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*);
  4954 SQLITE_API void sqlite3_value_free(sqlite3_value*);
  4955 
  4956 /*
  4957 ** CAPI3REF: Obtain Aggregate Function Context
  4958 ** METHOD: sqlite3_context
  4959 **
  4960 ** Implementations of aggregate SQL functions use this
  4961 ** routine to allocate memory for storing their state.
  4962 **
  4963 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called 
  4964 ** for a particular aggregate function, SQLite
  4965 ** allocates N of memory, zeroes out that memory, and returns a pointer
  4966 ** to the new memory. ^On second and subsequent calls to
  4967 ** sqlite3_aggregate_context() for the same aggregate function instance,
  4968 ** the same buffer is returned.  Sqlite3_aggregate_context() is normally
  4969 ** called once for each invocation of the xStep callback and then one
  4970 ** last time when the xFinal callback is invoked.  ^(When no rows match
  4971 ** an aggregate query, the xStep() callback of the aggregate function
  4972 ** implementation is never called and xFinal() is called exactly once.
  4973 ** In those cases, sqlite3_aggregate_context() might be called for the
  4974 ** first time from within xFinal().)^
  4975 **
  4976 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer 
  4977 ** when first called if N is less than or equal to zero or if a memory
  4978 ** allocate error occurs.
  4979 **
  4980 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
  4981 ** determined by the N parameter on first successful call.  Changing the
  4982 ** value of N in subsequent call to sqlite3_aggregate_context() within
  4983 ** the same aggregate function instance will not resize the memory
  4984 ** allocation.)^  Within the xFinal callback, it is customary to set
  4985 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no 
  4986 ** pointless memory allocations occur.
  4987 **
  4988 ** ^SQLite automatically frees the memory allocated by 
  4989 ** sqlite3_aggregate_context() when the aggregate query concludes.
  4990 **
  4991 ** The first parameter must be a copy of the
  4992 ** [sqlite3_context | SQL function context] that is the first parameter
  4993 ** to the xStep or xFinal callback routine that implements the aggregate
  4994 ** function.
  4995 **
  4996 ** This routine must be called from the same thread in which
  4997 ** the aggregate SQL function is running.
  4998 */
  4999 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
  5000 
  5001 /*
  5002 ** CAPI3REF: User Data For Functions
  5003 ** METHOD: sqlite3_context
  5004 **
  5005 ** ^The sqlite3_user_data() interface returns a copy of
  5006 ** the pointer that was the pUserData parameter (the 5th parameter)
  5007 ** of the [sqlite3_create_function()]
  5008 ** and [sqlite3_create_function16()] routines that originally
  5009 ** registered the application defined function.
  5010 **
  5011 ** This routine must be called from the same thread in which
  5012 ** the application-defined function is running.
  5013 */
  5014 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
  5015 
  5016 /*
  5017 ** CAPI3REF: Database Connection For Functions
  5018 ** METHOD: sqlite3_context
  5019 **
  5020 ** ^The sqlite3_context_db_handle() interface returns a copy of
  5021 ** the pointer to the [database connection] (the 1st parameter)
  5022 ** of the [sqlite3_create_function()]
  5023 ** and [sqlite3_create_function16()] routines that originally
  5024 ** registered the application defined function.
  5025 */
  5026 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
  5027 
  5028 /*
  5029 ** CAPI3REF: Function Auxiliary Data
  5030 ** METHOD: sqlite3_context
  5031 **
  5032 ** These functions may be used by (non-aggregate) SQL functions to
  5033 ** associate metadata with argument values. If the same value is passed to
  5034 ** multiple invocations of the same SQL function during query execution, under
  5035 ** some circumstances the associated metadata may be preserved.  An example
  5036 ** of where this might be useful is in a regular-expression matching
  5037 ** function. The compiled version of the regular expression can be stored as
  5038 ** metadata associated with the pattern string.  
  5039 ** Then as long as the pattern string remains the same,
  5040 ** the compiled regular expression can be reused on multiple
  5041 ** invocations of the same function.
  5042 **
  5043 ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
  5044 ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
  5045 ** value to the application-defined function.  ^N is zero for the left-most
  5046 ** function argument.  ^If there is no metadata
  5047 ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
  5048 ** returns a NULL pointer.
  5049 **
  5050 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
  5051 ** argument of the application-defined function.  ^Subsequent
  5052 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
  5053 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
  5054 ** NULL if the metadata has been discarded.
  5055 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
  5056 ** SQLite will invoke the destructor function X with parameter P exactly
  5057 ** once, when the metadata is discarded.
  5058 ** SQLite is free to discard the metadata at any time, including: <ul>
  5059 ** <li> ^(when the corresponding function parameter changes)^, or
  5060 ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
  5061 **      SQL statement)^, or
  5062 ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
  5063 **       parameter)^, or
  5064 ** <li> ^(during the original sqlite3_set_auxdata() call when a memory 
  5065 **      allocation error occurs.)^ </ul>
  5066 **
  5067 ** Note the last bullet in particular.  The destructor X in 
  5068 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
  5069 ** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()
  5070 ** should be called near the end of the function implementation and the
  5071 ** function implementation should not make any use of P after
  5072 ** sqlite3_set_auxdata() has been called.
  5073 **
  5074 ** ^(In practice, metadata is preserved between function calls for
  5075 ** function parameters that are compile-time constants, including literal
  5076 ** values and [parameters] and expressions composed from the same.)^
  5077 **
  5078 ** The value of the N parameter to these interfaces should be non-negative.
  5079 ** Future enhancements may make use of negative N values to define new
  5080 ** kinds of function caching behavior.
  5081 **
  5082 ** These routines must be called from the same thread in which
  5083 ** the SQL function is running.
  5084 */
  5085 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
  5086 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
  5087 
  5088 
  5089 /*
  5090 ** CAPI3REF: Constants Defining Special Destructor Behavior
  5091 **
  5092 ** These are special values for the destructor that is passed in as the
  5093 ** final argument to routines like [sqlite3_result_blob()].  ^If the destructor
  5094 ** argument is SQLITE_STATIC, it means that the content pointer is constant
  5095 ** and will never change.  It does not need to be destroyed.  ^The
  5096 ** SQLITE_TRANSIENT value means that the content will likely change in
  5097 ** the near future and that SQLite should make its own private copy of
  5098 ** the content before returning.
  5099 **
  5100 ** The typedef is necessary to work around problems in certain
  5101 ** C++ compilers.
  5102 */
  5103 typedef void (*sqlite3_destructor_type)(void*);
  5104 #define SQLITE_STATIC      ((sqlite3_destructor_type)0)
  5105 #define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
  5106 
  5107 /*
  5108 ** CAPI3REF: Setting The Result Of An SQL Function
  5109 ** METHOD: sqlite3_context
  5110 **
  5111 ** These routines are used by the xFunc or xFinal callbacks that
  5112 ** implement SQL functions and aggregates.  See
  5113 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
  5114 ** for additional information.
  5115 **
  5116 ** These functions work very much like the [parameter binding] family of
  5117 ** functions used to bind values to host parameters in prepared statements.
  5118 ** Refer to the [SQL parameter] documentation for additional information.
  5119 **
  5120 ** ^The sqlite3_result_blob() interface sets the result from
  5121 ** an application-defined function to be the BLOB whose content is pointed
  5122 ** to by the second parameter and which is N bytes long where N is the
  5123 ** third parameter.
  5124 **
  5125 ** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)
  5126 ** interfaces set the result of the application-defined function to be
  5127 ** a BLOB containing all zero bytes and N bytes in size.
  5128 **
  5129 ** ^The sqlite3_result_double() interface sets the result from
  5130 ** an application-defined function to be a floating point value specified
  5131 ** by its 2nd argument.
  5132 **
  5133 ** ^The sqlite3_result_error() and sqlite3_result_error16() functions
  5134 ** cause the implemented SQL function to throw an exception.
  5135 ** ^SQLite uses the string pointed to by the
  5136 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
  5137 ** as the text of an error message.  ^SQLite interprets the error
  5138 ** message string from sqlite3_result_error() as UTF-8. ^SQLite
  5139 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
  5140 ** byte order.  ^If the third parameter to sqlite3_result_error()
  5141 ** or sqlite3_result_error16() is negative then SQLite takes as the error
  5142 ** message all text up through the first zero character.
  5143 ** ^If the third parameter to sqlite3_result_error() or
  5144 ** sqlite3_result_error16() is non-negative then SQLite takes that many
  5145 ** bytes (not characters) from the 2nd parameter as the error message.
  5146 ** ^The sqlite3_result_error() and sqlite3_result_error16()
  5147 ** routines make a private copy of the error message text before
  5148 ** they return.  Hence, the calling function can deallocate or
  5149 ** modify the text after they return without harm.
  5150 ** ^The sqlite3_result_error_code() function changes the error code
  5151 ** returned by SQLite as a result of an error in a function.  ^By default,
  5152 ** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()
  5153 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
  5154 **
  5155 ** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an
  5156 ** error indicating that a string or BLOB is too long to represent.
  5157 **
  5158 ** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an
  5159 ** error indicating that a memory allocation failed.
  5160 **
  5161 ** ^The sqlite3_result_int() interface sets the return value
  5162 ** of the application-defined function to be the 32-bit signed integer
  5163 ** value given in the 2nd argument.
  5164 ** ^The sqlite3_result_int64() interface sets the return value
  5165 ** of the application-defined function to be the 64-bit signed integer
  5166 ** value given in the 2nd argument.
  5167 **
  5168 ** ^The sqlite3_result_null() interface sets the return value
  5169 ** of the application-defined function to be NULL.
  5170 **
  5171 ** ^The sqlite3_result_text(), sqlite3_result_text16(),
  5172 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
  5173 ** set the return value of the application-defined function to be
  5174 ** a text string which is represented as UTF-8, UTF-16 native byte order,
  5175 ** UTF-16 little endian, or UTF-16 big endian, respectively.
  5176 ** ^The sqlite3_result_text64() interface sets the return value of an
  5177 ** application-defined function to be a text string in an encoding
  5178 ** specified by the fifth (and last) parameter, which must be one
  5179 ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
  5180 ** ^SQLite takes the text result from the application from
  5181 ** the 2nd parameter of the sqlite3_result_text* interfaces.
  5182 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  5183 ** is negative, then SQLite takes result text from the 2nd parameter
  5184 ** through the first zero character.
  5185 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
  5186 ** is non-negative, then as many bytes (not characters) of the text
  5187 ** pointed to by the 2nd parameter are taken as the application-defined
  5188 ** function result.  If the 3rd parameter is non-negative, then it
  5189 ** must be the byte offset into the string where the NUL terminator would
  5190 ** appear if the string where NUL terminated.  If any NUL characters occur
  5191 ** in the string at a byte offset that is less than the value of the 3rd
  5192 ** parameter, then the resulting string will contain embedded NULs and the
  5193 ** result of expressions operating on strings with embedded NULs is undefined.
  5194 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
  5195 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
  5196 ** function as the destructor on the text or BLOB result when it has
  5197 ** finished using that result.
  5198 ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
  5199 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
  5200 ** assumes that the text or BLOB result is in constant space and does not
  5201 ** copy the content of the parameter nor call a destructor on the content
  5202 ** when it has finished using that result.
  5203 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
  5204 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
  5205 ** then SQLite makes a copy of the result into space obtained from
  5206 ** from [sqlite3_malloc()] before it returns.
  5207 **
  5208 ** ^The sqlite3_result_value() interface sets the result of
  5209 ** the application-defined function to be a copy of the
  5210 ** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The
  5211 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  5212 ** so that the [sqlite3_value] specified in the parameter may change or
  5213 ** be deallocated after sqlite3_result_value() returns without harm.
  5214 ** ^A [protected sqlite3_value] object may always be used where an
  5215 ** [unprotected sqlite3_value] object is required, so either
  5216 ** kind of [sqlite3_value] object can be used with this interface.
  5217 **
  5218 ** If these routines are called from within the different thread
  5219 ** than the one containing the application-defined function that received
  5220 ** the [sqlite3_context] pointer, the results are undefined.
  5221 */
  5222 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
  5223 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
  5224                            sqlite3_uint64,void(*)(void*));
  5225 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
  5226 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
  5227 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
  5228 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
  5229 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
  5230 SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
  5231 SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
  5232 SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
  5233 SQLITE_API void sqlite3_result_null(sqlite3_context*);
  5234 SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  5235 SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
  5236                            void(*)(void*), unsigned char encoding);
  5237 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  5238 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  5239 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  5240 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  5241 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
  5242 SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
  5243 
  5244 
  5245 /*
  5246 ** CAPI3REF: Setting The Subtype Of An SQL Function
  5247 ** METHOD: sqlite3_context
  5248 **
  5249 ** The sqlite3_result_subtype(C,T) function causes the subtype of
  5250 ** the result from the [application-defined SQL function] with 
  5251 ** [sqlite3_context] C to be the value T.  Only the lower 8 bits 
  5252 ** of the subtype T are preserved in current versions of SQLite;
  5253 ** higher order bits are discarded.
  5254 ** The number of subtype bytes preserved by SQLite might increase
  5255 ** in future releases of SQLite.
  5256 */
  5257 SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);
  5258 
  5259 /*
  5260 ** CAPI3REF: Define New Collating Sequences
  5261 ** METHOD: sqlite3
  5262 **
  5263 ** ^These functions add, remove, or modify a [collation] associated
  5264 ** with the [database connection] specified as the first argument.
  5265 **
  5266 ** ^The name of the collation is a UTF-8 string
  5267 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
  5268 ** and a UTF-16 string in native byte order for sqlite3_create_collation16().
  5269 ** ^Collation names that compare equal according to [sqlite3_strnicmp()] are
  5270 ** considered to be the same name.
  5271 **
  5272 ** ^(The third argument (eTextRep) must be one of the constants:
  5273 ** <ul>
  5274 ** <li> [SQLITE_UTF8],
  5275 ** <li> [SQLITE_UTF16LE],
  5276 ** <li> [SQLITE_UTF16BE],
  5277 ** <li> [SQLITE_UTF16], or
  5278 ** <li> [SQLITE_UTF16_ALIGNED].
  5279 ** </ul>)^
  5280 ** ^The eTextRep argument determines the encoding of strings passed
  5281 ** to the collating function callback, xCallback.
  5282 ** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep
  5283 ** force strings to be UTF16 with native byte order.
  5284 ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin
  5285 ** on an even byte address.
  5286 **
  5287 ** ^The fourth argument, pArg, is an application data pointer that is passed
  5288 ** through as the first argument to the collating function callback.
  5289 **
  5290 ** ^The fifth argument, xCallback, is a pointer to the collating function.
  5291 ** ^Multiple collating functions can be registered using the same name but
  5292 ** with different eTextRep parameters and SQLite will use whichever
  5293 ** function requires the least amount of data transformation.
  5294 ** ^If the xCallback argument is NULL then the collating function is
  5295 ** deleted.  ^When all collating functions having the same name are deleted,
  5296 ** that collation is no longer usable.
  5297 **
  5298 ** ^The collating function callback is invoked with a copy of the pArg 
  5299 ** application data pointer and with two strings in the encoding specified
  5300 ** by the eTextRep argument.  The collating function must return an
  5301 ** integer that is negative, zero, or positive
  5302 ** if the first string is less than, equal to, or greater than the second,
  5303 ** respectively.  A collating function must always return the same answer
  5304 ** given the same inputs.  If two or more collating functions are registered
  5305 ** to the same collation name (using different eTextRep values) then all
  5306 ** must give an equivalent answer when invoked with equivalent strings.
  5307 ** The collating function must obey the following properties for all
  5308 ** strings A, B, and C:
  5309 **
  5310 ** <ol>
  5311 ** <li> If A==B then B==A.
  5312 ** <li> If A==B and B==C then A==C.
  5313 ** <li> If A&lt;B THEN B&gt;A.
  5314 ** <li> If A&lt;B and B&lt;C then A&lt;C.
  5315 ** </ol>
  5316 **
  5317 ** If a collating function fails any of the above constraints and that
  5318 ** collating function is  registered and used, then the behavior of SQLite
  5319 ** is undefined.
  5320 **
  5321 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
  5322 ** with the addition that the xDestroy callback is invoked on pArg when
  5323 ** the collating function is deleted.
  5324 ** ^Collating functions are deleted when they are overridden by later
  5325 ** calls to the collation creation functions or when the
  5326 ** [database connection] is closed using [sqlite3_close()].
  5327 **
  5328 ** ^The xDestroy callback is <u>not</u> called if the 
  5329 ** sqlite3_create_collation_v2() function fails.  Applications that invoke
  5330 ** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should 
  5331 ** check the return code and dispose of the application data pointer
  5332 ** themselves rather than expecting SQLite to deal with it for them.
  5333 ** This is different from every other SQLite interface.  The inconsistency 
  5334 ** is unfortunate but cannot be changed without breaking backwards 
  5335 ** compatibility.
  5336 **
  5337 ** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
  5338 */
  5339 SQLITE_API int sqlite3_create_collation(
  5340   sqlite3*, 
  5341   const char *zName, 
  5342   int eTextRep, 
  5343   void *pArg,
  5344   int(*xCompare)(void*,int,const void*,int,const void*)
  5345 );
  5346 SQLITE_API int sqlite3_create_collation_v2(
  5347   sqlite3*, 
  5348   const char *zName, 
  5349   int eTextRep, 
  5350   void *pArg,
  5351   int(*xCompare)(void*,int,const void*,int,const void*),
  5352   void(*xDestroy)(void*)
  5353 );
  5354 SQLITE_API int sqlite3_create_collation16(
  5355   sqlite3*, 
  5356   const void *zName,
  5357   int eTextRep, 
  5358   void *pArg,
  5359   int(*xCompare)(void*,int,const void*,int,const void*)
  5360 );
  5361 
  5362 /*
  5363 ** CAPI3REF: Collation Needed Callbacks
  5364 ** METHOD: sqlite3
  5365 **
  5366 ** ^To avoid having to register all collation sequences before a database
  5367 ** can be used, a single callback function may be registered with the
  5368 ** [database connection] to be invoked whenever an undefined collation
  5369 ** sequence is required.
  5370 **
  5371 ** ^If the function is registered using the sqlite3_collation_needed() API,
  5372 ** then it is passed the names of undefined collation sequences as strings
  5373 ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
  5374 ** the names are passed as UTF-16 in machine native byte order.
  5375 ** ^A call to either function replaces the existing collation-needed callback.
  5376 **
  5377 ** ^(When the callback is invoked, the first argument passed is a copy
  5378 ** of the second argument to sqlite3_collation_needed() or
  5379 ** sqlite3_collation_needed16().  The second argument is the database
  5380 ** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
  5381 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
  5382 ** sequence function required.  The fourth parameter is the name of the
  5383 ** required collation sequence.)^
  5384 **
  5385 ** The callback function should register the desired collation using
  5386 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
  5387 ** [sqlite3_create_collation_v2()].
  5388 */
  5389 SQLITE_API int sqlite3_collation_needed(
  5390   sqlite3*, 
  5391   void*, 
  5392   void(*)(void*,sqlite3*,int eTextRep,const char*)
  5393 );
  5394 SQLITE_API int sqlite3_collation_needed16(
  5395   sqlite3*, 
  5396   void*,
  5397   void(*)(void*,sqlite3*,int eTextRep,const void*)
  5398 );
  5399 
  5400 #ifdef SQLITE_HAS_CODEC
  5401 /*
  5402 ** Specify the key for an encrypted database.  This routine should be
  5403 ** called right after sqlite3_open().
  5404 **
  5405 ** The code to implement this API is not available in the public release
  5406 ** of SQLite.
  5407 */
  5408 SQLITE_API int sqlite3_key(
  5409   sqlite3 *db,                   /* Database to be rekeyed */
  5410   const void *pKey, int nKey     /* The key */
  5411 );
  5412 SQLITE_API int sqlite3_key_v2(
  5413   sqlite3 *db,                   /* Database to be rekeyed */
  5414   const char *zDbName,           /* Name of the database */
  5415   const void *pKey, int nKey     /* The key */
  5416 );
  5417 
  5418 /*
  5419 ** Change the key on an open database.  If the current database is not
  5420 ** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the
  5421 ** database is decrypted.
  5422 **
  5423 ** The code to implement this API is not available in the public release
  5424 ** of SQLite.
  5425 */
  5426 SQLITE_API int sqlite3_rekey(
  5427   sqlite3 *db,                   /* Database to be rekeyed */
  5428   const void *pKey, int nKey     /* The new key */
  5429 );
  5430 SQLITE_API int sqlite3_rekey_v2(
  5431   sqlite3 *db,                   /* Database to be rekeyed */
  5432   const char *zDbName,           /* Name of the database */
  5433   const void *pKey, int nKey     /* The new key */
  5434 );
  5435 
  5436 /*
  5437 ** Specify the activation key for a SEE database.  Unless 
  5438 ** activated, none of the SEE routines will work.
  5439 */
  5440 SQLITE_API void sqlite3_activate_see(
  5441   const char *zPassPhrase        /* Activation phrase */
  5442 );
  5443 #endif
  5444 
  5445 #ifdef SQLITE_ENABLE_CEROD
  5446 /*
  5447 ** Specify the activation key for a CEROD database.  Unless 
  5448 ** activated, none of the CEROD routines will work.
  5449 */
  5450 SQLITE_API void sqlite3_activate_cerod(
  5451   const char *zPassPhrase        /* Activation phrase */
  5452 );
  5453 #endif
  5454 
  5455 /*
  5456 ** CAPI3REF: Suspend Execution For A Short Time
  5457 **
  5458 ** The sqlite3_sleep() function causes the current thread to suspend execution
  5459 ** for at least a number of milliseconds specified in its parameter.
  5460 **
  5461 ** If the operating system does not support sleep requests with
  5462 ** millisecond time resolution, then the time will be rounded up to
  5463 ** the nearest second. The number of milliseconds of sleep actually
  5464 ** requested from the operating system is returned.
  5465 **
  5466 ** ^SQLite implements this interface by calling the xSleep()
  5467 ** method of the default [sqlite3_vfs] object.  If the xSleep() method
  5468 ** of the default VFS is not implemented correctly, or not implemented at
  5469 ** all, then the behavior of sqlite3_sleep() may deviate from the description
  5470 ** in the previous paragraphs.
  5471 */
  5472 SQLITE_API int sqlite3_sleep(int);
  5473 
  5474 /*
  5475 ** CAPI3REF: Name Of The Folder Holding Temporary Files
  5476 **
  5477 ** ^(If this global variable is made to point to a string which is
  5478 ** the name of a folder (a.k.a. directory), then all temporary files
  5479 ** created by SQLite when using a built-in [sqlite3_vfs | VFS]
  5480 ** will be placed in that directory.)^  ^If this variable
  5481 ** is a NULL pointer, then SQLite performs a search for an appropriate
  5482 ** temporary file directory.
  5483 **
  5484 ** Applications are strongly discouraged from using this global variable.
  5485 ** It is required to set a temporary folder on Windows Runtime (WinRT).
  5486 ** But for all other platforms, it is highly recommended that applications
  5487 ** neither read nor write this variable.  This global variable is a relic
  5488 ** that exists for backwards compatibility of legacy applications and should
  5489 ** be avoided in new projects.
  5490 **
  5491 ** It is not safe to read or modify this variable in more than one
  5492 ** thread at a time.  It is not safe to read or modify this variable
  5493 ** if a [database connection] is being used at the same time in a separate
  5494 ** thread.
  5495 ** It is intended that this variable be set once
  5496 ** as part of process initialization and before any SQLite interface
  5497 ** routines have been called and that this variable remain unchanged
  5498 ** thereafter.
  5499 **
  5500 ** ^The [temp_store_directory pragma] may modify this variable and cause
  5501 ** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
  5502 ** the [temp_store_directory pragma] always assumes that any string
  5503 ** that this variable points to is held in memory obtained from 
  5504 ** [sqlite3_malloc] and the pragma may attempt to free that memory
  5505 ** using [sqlite3_free].
  5506 ** Hence, if this variable is modified directly, either it should be
  5507 ** made NULL or made to point to memory obtained from [sqlite3_malloc]
  5508 ** or else the use of the [temp_store_directory pragma] should be avoided.
  5509 ** Except when requested by the [temp_store_directory pragma], SQLite
  5510 ** does not free the memory that sqlite3_temp_directory points to.  If
  5511 ** the application wants that memory to be freed, it must do
  5512 ** so itself, taking care to only do so after all [database connection]
  5513 ** objects have been destroyed.
  5514 **
  5515 ** <b>Note to Windows Runtime users:</b>  The temporary directory must be set
  5516 ** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various
  5517 ** features that require the use of temporary files may fail.  Here is an
  5518 ** example of how to do this using C++ with the Windows Runtime:
  5519 **
  5520 ** <blockquote><pre>
  5521 ** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
  5522 ** &nbsp;     TemporaryFolder->Path->Data();
  5523 ** char zPathBuf&#91;MAX_PATH + 1&#93;;
  5524 ** memset(zPathBuf, 0, sizeof(zPathBuf));
  5525 ** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
  5526 ** &nbsp;     NULL, NULL);
  5527 ** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
  5528 ** </pre></blockquote>
  5529 */
  5530 SQLITE_API char *sqlite3_temp_directory;
  5531 
  5532 /*
  5533 ** CAPI3REF: Name Of The Folder Holding Database Files
  5534 **
  5535 ** ^(If this global variable is made to point to a string which is
  5536 ** the name of a folder (a.k.a. directory), then all database files
  5537 ** specified with a relative pathname and created or accessed by
  5538 ** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed
  5539 ** to be relative to that directory.)^ ^If this variable is a NULL
  5540 ** pointer, then SQLite assumes that all database files specified
  5541 ** with a relative pathname are relative to the current directory
  5542 ** for the process.  Only the windows VFS makes use of this global
  5543 ** variable; it is ignored by the unix VFS.
  5544 **
  5545 ** Changing the value of this variable while a database connection is
  5546 ** open can result in a corrupt database.
  5547 **
  5548 ** It is not safe to read or modify this variable in more than one
  5549 ** thread at a time.  It is not safe to read or modify this variable
  5550 ** if a [database connection] is being used at the same time in a separate
  5551 ** thread.
  5552 ** It is intended that this variable be set once
  5553 ** as part of process initialization and before any SQLite interface
  5554 ** routines have been called and that this variable remain unchanged
  5555 ** thereafter.
  5556 **
  5557 ** ^The [data_store_directory pragma] may modify this variable and cause
  5558 ** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,
  5559 ** the [data_store_directory pragma] always assumes that any string
  5560 ** that this variable points to is held in memory obtained from 
  5561 ** [sqlite3_malloc] and the pragma may attempt to free that memory
  5562 ** using [sqlite3_free].
  5563 ** Hence, if this variable is modified directly, either it should be
  5564 ** made NULL or made to point to memory obtained from [sqlite3_malloc]
  5565 ** or else the use of the [data_store_directory pragma] should be avoided.
  5566 */
  5567 SQLITE_API char *sqlite3_data_directory;
  5568 
  5569 /*
  5570 ** CAPI3REF: Test For Auto-Commit Mode
  5571 ** KEYWORDS: {autocommit mode}
  5572 ** METHOD: sqlite3
  5573 **
  5574 ** ^The sqlite3_get_autocommit() interface returns non-zero or
  5575 ** zero if the given database connection is or is not in autocommit mode,
  5576 ** respectively.  ^Autocommit mode is on by default.
  5577 ** ^Autocommit mode is disabled by a [BEGIN] statement.
  5578 ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
  5579 **
  5580 ** If certain kinds of errors occur on a statement within a multi-statement
  5581 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
  5582 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
  5583 ** transaction might be rolled back automatically.  The only way to
  5584 ** find out whether SQLite automatically rolled back the transaction after
  5585 ** an error is to use this function.
  5586 **
  5587 ** If another thread changes the autocommit status of the database
  5588 ** connection while this routine is running, then the return value
  5589 ** is undefined.
  5590 */
  5591 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
  5592 
  5593 /*
  5594 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
  5595 ** METHOD: sqlite3_stmt
  5596 **
  5597 ** ^The sqlite3_db_handle interface returns the [database connection] handle
  5598 ** to which a [prepared statement] belongs.  ^The [database connection]
  5599 ** returned by sqlite3_db_handle is the same [database connection]
  5600 ** that was the first argument
  5601 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
  5602 ** create the statement in the first place.
  5603 */
  5604 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
  5605 
  5606 /*
  5607 ** CAPI3REF: Return The Filename For A Database Connection
  5608 ** METHOD: sqlite3
  5609 **
  5610 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
  5611 ** associated with database N of connection D.  ^The main database file
  5612 ** has the name "main".  If there is no attached database N on the database
  5613 ** connection D, or if database N is a temporary or in-memory database, then
  5614 ** a NULL pointer is returned.
  5615 **
  5616 ** ^The filename returned by this function is the output of the
  5617 ** xFullPathname method of the [VFS].  ^In other words, the filename
  5618 ** will be an absolute pathname, even if the filename used
  5619 ** to open the database originally was a URI or relative pathname.
  5620 */
  5621 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
  5622 
  5623 /*
  5624 ** CAPI3REF: Determine if a database is read-only
  5625 ** METHOD: sqlite3
  5626 **
  5627 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
  5628 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
  5629 ** the name of a database on connection D.
  5630 */
  5631 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
  5632 
  5633 /*
  5634 ** CAPI3REF: Find the next prepared statement
  5635 ** METHOD: sqlite3
  5636 **
  5637 ** ^This interface returns a pointer to the next [prepared statement] after
  5638 ** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL
  5639 ** then this interface returns a pointer to the first prepared statement
  5640 ** associated with the database connection pDb.  ^If no prepared statement
  5641 ** satisfies the conditions of this routine, it returns NULL.
  5642 **
  5643 ** The [database connection] pointer D in a call to
  5644 ** [sqlite3_next_stmt(D,S)] must refer to an open database
  5645 ** connection and in particular must not be a NULL pointer.
  5646 */
  5647 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
  5648 
  5649 /*
  5650 ** CAPI3REF: Commit And Rollback Notification Callbacks
  5651 ** METHOD: sqlite3
  5652 **
  5653 ** ^The sqlite3_commit_hook() interface registers a callback
  5654 ** function to be invoked whenever a transaction is [COMMIT | committed].
  5655 ** ^Any callback set by a previous call to sqlite3_commit_hook()
  5656 ** for the same database connection is overridden.
  5657 ** ^The sqlite3_rollback_hook() interface registers a callback
  5658 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
  5659 ** ^Any callback set by a previous call to sqlite3_rollback_hook()
  5660 ** for the same database connection is overridden.
  5661 ** ^The pArg argument is passed through to the callback.
  5662 ** ^If the callback on a commit hook function returns non-zero,
  5663 ** then the commit is converted into a rollback.
  5664 **
  5665 ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
  5666 ** return the P argument from the previous call of the same function
  5667 ** on the same [database connection] D, or NULL for
  5668 ** the first call for each function on D.
  5669 **
  5670 ** The commit and rollback hook callbacks are not reentrant.
  5671 ** The callback implementation must not do anything that will modify
  5672 ** the database connection that invoked the callback.  Any actions
  5673 ** to modify the database connection must be deferred until after the
  5674 ** completion of the [sqlite3_step()] call that triggered the commit
  5675 ** or rollback hook in the first place.
  5676 ** Note that running any other SQL statements, including SELECT statements,
  5677 ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
  5678 ** the database connections for the meaning of "modify" in this paragraph.
  5679 **
  5680 ** ^Registering a NULL function disables the callback.
  5681 **
  5682 ** ^When the commit hook callback routine returns zero, the [COMMIT]
  5683 ** operation is allowed to continue normally.  ^If the commit hook
  5684 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
  5685 ** ^The rollback hook is invoked on a rollback that results from a commit
  5686 ** hook returning non-zero, just as it would be with any other rollback.
  5687 **
  5688 ** ^For the purposes of this API, a transaction is said to have been
  5689 ** rolled back if an explicit "ROLLBACK" statement is executed, or
  5690 ** an error or constraint causes an implicit rollback to occur.
  5691 ** ^The rollback callback is not invoked if a transaction is
  5692 ** automatically rolled back because the database connection is closed.
  5693 **
  5694 ** See also the [sqlite3_update_hook()] interface.
  5695 */
  5696 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
  5697 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
  5698 
  5699 /*
  5700 ** CAPI3REF: Data Change Notification Callbacks
  5701 ** METHOD: sqlite3
  5702 **
  5703 ** ^The sqlite3_update_hook() interface registers a callback function
  5704 ** with the [database connection] identified by the first argument
  5705 ** to be invoked whenever a row is updated, inserted or deleted in
  5706 ** a [rowid table].
  5707 ** ^Any callback set by a previous call to this function
  5708 ** for the same database connection is overridden.
  5709 **
  5710 ** ^The second argument is a pointer to the function to invoke when a
  5711 ** row is updated, inserted or deleted in a rowid table.
  5712 ** ^The first argument to the callback is a copy of the third argument
  5713 ** to sqlite3_update_hook().
  5714 ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
  5715 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
  5716 ** to be invoked.
  5717 ** ^The third and fourth arguments to the callback contain pointers to the
  5718 ** database and table name containing the affected row.
  5719 ** ^The final callback parameter is the [rowid] of the row.
  5720 ** ^In the case of an update, this is the [rowid] after the update takes place.
  5721 **
  5722 ** ^(The update hook is not invoked when internal system tables are
  5723 ** modified (i.e. sqlite_master and sqlite_sequence).)^
  5724 ** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.
  5725 **
  5726 ** ^In the current implementation, the update hook
  5727 ** is not invoked when conflicting rows are deleted because of an
  5728 ** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook
  5729 ** invoked when rows are deleted using the [truncate optimization].
  5730 ** The exceptions defined in this paragraph might change in a future
  5731 ** release of SQLite.
  5732 **
  5733 ** The update hook implementation must not do anything that will modify
  5734 ** the database connection that invoked the update hook.  Any actions
  5735 ** to modify the database connection must be deferred until after the
  5736 ** completion of the [sqlite3_step()] call that triggered the update hook.
  5737 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
  5738 ** database connections for the meaning of "modify" in this paragraph.
  5739 **
  5740 ** ^The sqlite3_update_hook(D,C,P) function
  5741 ** returns the P argument from the previous call
  5742 ** on the same [database connection] D, or NULL for
  5743 ** the first call on D.
  5744 **
  5745 ** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],
  5746 ** and [sqlite3_preupdate_hook()] interfaces.
  5747 */
  5748 SQLITE_API void *sqlite3_update_hook(
  5749   sqlite3*, 
  5750   void(*)(void *,int ,char const *,char const *,sqlite3_int64),
  5751   void*
  5752 );
  5753 
  5754 /*
  5755 ** CAPI3REF: Enable Or Disable Shared Pager Cache
  5756 **
  5757 ** ^(This routine enables or disables the sharing of the database cache
  5758 ** and schema data structures between [database connection | connections]
  5759 ** to the same database. Sharing is enabled if the argument is true
  5760 ** and disabled if the argument is false.)^
  5761 **
  5762 ** ^Cache sharing is enabled and disabled for an entire process.
  5763 ** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). 
  5764 ** In prior versions of SQLite,
  5765 ** sharing was enabled or disabled for each thread separately.
  5766 **
  5767 ** ^(The cache sharing mode set by this interface effects all subsequent
  5768 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
  5769 ** Existing database connections continue use the sharing mode
  5770 ** that was in effect at the time they were opened.)^
  5771 **
  5772 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
  5773 ** successfully.  An [error code] is returned otherwise.)^
  5774 **
  5775 ** ^Shared cache is disabled by default. But this might change in
  5776 ** future releases of SQLite.  Applications that care about shared
  5777 ** cache setting should set it explicitly.
  5778 **
  5779 ** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
  5780 ** and will always return SQLITE_MISUSE. On those systems, 
  5781 ** shared cache mode should be enabled per-database connection via 
  5782 ** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
  5783 **
  5784 ** This interface is threadsafe on processors where writing a
  5785 ** 32-bit integer is atomic.
  5786 **
  5787 ** See Also:  [SQLite Shared-Cache Mode]
  5788 */
  5789 SQLITE_API int sqlite3_enable_shared_cache(int);
  5790 
  5791 /*
  5792 ** CAPI3REF: Attempt To Free Heap Memory
  5793 **
  5794 ** ^The sqlite3_release_memory() interface attempts to free N bytes
  5795 ** of heap memory by deallocating non-essential memory allocations
  5796 ** held by the database library.   Memory used to cache database
  5797 ** pages to improve performance is an example of non-essential memory.
  5798 ** ^sqlite3_release_memory() returns the number of bytes actually freed,
  5799 ** which might be more or less than the amount requested.
  5800 ** ^The sqlite3_release_memory() routine is a no-op returning zero
  5801 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  5802 **
  5803 ** See also: [sqlite3_db_release_memory()]
  5804 */
  5805 SQLITE_API int sqlite3_release_memory(int);
  5806 
  5807 /*
  5808 ** CAPI3REF: Free Memory Used By A Database Connection
  5809 ** METHOD: sqlite3
  5810 **
  5811 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
  5812 ** memory as possible from database connection D. Unlike the
  5813 ** [sqlite3_release_memory()] interface, this interface is in effect even
  5814 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
  5815 ** omitted.
  5816 **
  5817 ** See also: [sqlite3_release_memory()]
  5818 */
  5819 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
  5820 
  5821 /*
  5822 ** CAPI3REF: Impose A Limit On Heap Size
  5823 **
  5824 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
  5825 ** soft limit on the amount of heap memory that may be allocated by SQLite.
  5826 ** ^SQLite strives to keep heap memory utilization below the soft heap
  5827 ** limit by reducing the number of pages held in the page cache
  5828 ** as heap memory usages approaches the limit.
  5829 ** ^The soft heap limit is "soft" because even though SQLite strives to stay
  5830 ** below the limit, it will exceed the limit rather than generate
  5831 ** an [SQLITE_NOMEM] error.  In other words, the soft heap limit 
  5832 ** is advisory only.
  5833 **
  5834 ** ^The return value from sqlite3_soft_heap_limit64() is the size of
  5835 ** the soft heap limit prior to the call, or negative in the case of an
  5836 ** error.  ^If the argument N is negative
  5837 ** then no change is made to the soft heap limit.  Hence, the current
  5838 ** size of the soft heap limit can be determined by invoking
  5839 ** sqlite3_soft_heap_limit64() with a negative argument.
  5840 **
  5841 ** ^If the argument N is zero then the soft heap limit is disabled.
  5842 **
  5843 ** ^(The soft heap limit is not enforced in the current implementation
  5844 ** if one or more of following conditions are true:
  5845 **
  5846 ** <ul>
  5847 ** <li> The soft heap limit is set to zero.
  5848 ** <li> Memory accounting is disabled using a combination of the
  5849 **      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
  5850 **      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
  5851 ** <li> An alternative page cache implementation is specified using
  5852 **      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
  5853 ** <li> The page cache allocates from its own memory pool supplied
  5854 **      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
  5855 **      from the heap.
  5856 ** </ul>)^
  5857 **
  5858 ** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), 
  5859 ** the soft heap limit is enforced
  5860 ** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]
  5861 ** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],
  5862 ** the soft heap limit is enforced on every memory allocation.  Without
  5863 ** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced
  5864 ** when memory is allocated by the page cache.  Testing suggests that because
  5865 ** the page cache is the predominate memory user in SQLite, most
  5866 ** applications will achieve adequate soft heap limit enforcement without
  5867 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
  5868 **
  5869 ** The circumstances under which SQLite will enforce the soft heap limit may
  5870 ** changes in future releases of SQLite.
  5871 */
  5872 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
  5873 
  5874 /*
  5875 ** CAPI3REF: Deprecated Soft Heap Limit Interface
  5876 ** DEPRECATED
  5877 **
  5878 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
  5879 ** interface.  This routine is provided for historical compatibility
  5880 ** only.  All new applications should use the
  5881 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
  5882 */
  5883 SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
  5884 
  5885 
  5886 /*
  5887 ** CAPI3REF: Extract Metadata About A Column Of A Table
  5888 ** METHOD: sqlite3
  5889 **
  5890 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
  5891 ** information about column C of table T in database D
  5892 ** on [database connection] X.)^  ^The sqlite3_table_column_metadata()
  5893 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
  5894 ** the final five arguments with appropriate values if the specified
  5895 ** column exists.  ^The sqlite3_table_column_metadata() interface returns
  5896 ** SQLITE_ERROR and if the specified column does not exist.
  5897 ** ^If the column-name parameter to sqlite3_table_column_metadata() is a
  5898 ** NULL pointer, then this routine simply checks for the existence of the
  5899 ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
  5900 ** does not.
  5901 **
  5902 ** ^The column is identified by the second, third and fourth parameters to
  5903 ** this function. ^(The second parameter is either the name of the database
  5904 ** (i.e. "main", "temp", or an attached database) containing the specified
  5905 ** table or NULL.)^ ^If it is NULL, then all attached databases are searched
  5906 ** for the table using the same algorithm used by the database engine to
  5907 ** resolve unqualified table references.
  5908 **
  5909 ** ^The third and fourth parameters to this function are the table and column
  5910 ** name of the desired column, respectively.
  5911 **
  5912 ** ^Metadata is returned by writing to the memory locations passed as the 5th
  5913 ** and subsequent parameters to this function. ^Any of these arguments may be
  5914 ** NULL, in which case the corresponding element of metadata is omitted.
  5915 **
  5916 ** ^(<blockquote>
  5917 ** <table border="1">
  5918 ** <tr><th> Parameter <th> Output<br>Type <th>  Description
  5919 **
  5920 ** <tr><td> 5th <td> const char* <td> Data type
  5921 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
  5922 ** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint
  5923 ** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY
  5924 ** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]
  5925 ** </table>
  5926 ** </blockquote>)^
  5927 **
  5928 ** ^The memory pointed to by the character pointers returned for the
  5929 ** declaration type and collation sequence is valid until the next
  5930 ** call to any SQLite API function.
  5931 **
  5932 ** ^If the specified table is actually a view, an [error code] is returned.
  5933 **
  5934 ** ^If the specified column is "rowid", "oid" or "_rowid_" and the table 
  5935 ** is not a [WITHOUT ROWID] table and an
  5936 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
  5937 ** parameters are set for the explicitly declared column. ^(If there is no
  5938 ** [INTEGER PRIMARY KEY] column, then the outputs
  5939 ** for the [rowid] are set as follows:
  5940 **
  5941 ** <pre>
  5942 **     data type: "INTEGER"
  5943 **     collation sequence: "BINARY"
  5944 **     not null: 0
  5945 **     primary key: 1
  5946 **     auto increment: 0
  5947 ** </pre>)^
  5948 **
  5949 ** ^This function causes all database schemas to be read from disk and
  5950 ** parsed, if that has not already been done, and returns an error if
  5951 ** any errors are encountered while loading the schema.
  5952 */
  5953 SQLITE_API int sqlite3_table_column_metadata(
  5954   sqlite3 *db,                /* Connection handle */
  5955   const char *zDbName,        /* Database name or NULL */
  5956   const char *zTableName,     /* Table name */
  5957   const char *zColumnName,    /* Column name */
  5958   char const **pzDataType,    /* OUTPUT: Declared data type */
  5959   char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
  5960   int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
  5961   int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
  5962   int *pAutoinc               /* OUTPUT: True if column is auto-increment */
  5963 );
  5964 
  5965 /*
  5966 ** CAPI3REF: Load An Extension
  5967 ** METHOD: sqlite3
  5968 **
  5969 ** ^This interface loads an SQLite extension library from the named file.
  5970 **
  5971 ** ^The sqlite3_load_extension() interface attempts to load an
  5972 ** [SQLite extension] library contained in the file zFile.  If
  5973 ** the file cannot be loaded directly, attempts are made to load
  5974 ** with various operating-system specific extensions added.
  5975 ** So for example, if "samplelib" cannot be loaded, then names like
  5976 ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
  5977 ** be tried also.
  5978 **
  5979 ** ^The entry point is zProc.
  5980 ** ^(zProc may be 0, in which case SQLite will try to come up with an
  5981 ** entry point name on its own.  It first tries "sqlite3_extension_init".
  5982 ** If that does not work, it constructs a name "sqlite3_X_init" where the
  5983 ** X is consists of the lower-case equivalent of all ASCII alphabetic
  5984 ** characters in the filename from the last "/" to the first following
  5985 ** "." and omitting any initial "lib".)^
  5986 ** ^The sqlite3_load_extension() interface returns
  5987 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
  5988 ** ^If an error occurs and pzErrMsg is not 0, then the
  5989 ** [sqlite3_load_extension()] interface shall attempt to
  5990 ** fill *pzErrMsg with error message text stored in memory
  5991 ** obtained from [sqlite3_malloc()]. The calling function
  5992 ** should free this memory by calling [sqlite3_free()].
  5993 **
  5994 ** ^Extension loading must be enabled using
  5995 ** [sqlite3_enable_load_extension()] or
  5996 ** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)
  5997 ** prior to calling this API,
  5998 ** otherwise an error will be returned.
  5999 **
  6000 ** <b>Security warning:</b> It is recommended that the 
  6001 ** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this
  6002 ** interface.  The use of the [sqlite3_enable_load_extension()] interface
  6003 ** should be avoided.  This will keep the SQL function [load_extension()]
  6004 ** disabled and prevent SQL injections from giving attackers
  6005 ** access to extension loading capabilities.
  6006 **
  6007 ** See also the [load_extension() SQL function].
  6008 */
  6009 SQLITE_API int sqlite3_load_extension(
  6010   sqlite3 *db,          /* Load the extension into this database connection */
  6011   const char *zFile,    /* Name of the shared library containing extension */
  6012   const char *zProc,    /* Entry point.  Derived from zFile if 0 */
  6013   char **pzErrMsg       /* Put error message here if not 0 */
  6014 );
  6015 
  6016 /*
  6017 ** CAPI3REF: Enable Or Disable Extension Loading
  6018 ** METHOD: sqlite3
  6019 **
  6020 ** ^So as not to open sec