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