src/sqlite3.c
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4142 3053a46b8b56
child 4196 371b6e6c8df6
child 4792 7056435ab9e7
permissions -rw-r--r--
forgot test files
vb@130
     1
/******************************************************************************
vb@130
     2
** This file is an amalgamation of many separate C source files from SQLite
dz@3192
     3
** version 3.26.0.  By combining all the individual C code files into this
vb@130
     4
** single large file, the entire code can be compiled as a single translation
vb@130
     5
** unit.  This allows many compilers to do optimizations that would not be
vb@130
     6
** possible if the files were compiled separately.  Performance improvements
vb@130
     7
** of 5% or more are commonly seen when SQLite is compiled as a single
vb@130
     8
** translation unit.
vb@130
     9
**
vb@130
    10
** This file is all you need to compile SQLite.  To use SQLite in other
vb@130
    11
** programs, you need this file and the "sqlite3.h" header file that defines
edouard@1912
    12
** the programming interface to the SQLite library.  (If you do not have
vb@130
    13
** the "sqlite3.h" header file at hand, you will find a copy embedded within
vb@130
    14
** the text of this file.  Search for "Begin file sqlite3.h" to find the start
vb@130
    15
** of the embedded sqlite3.h header file.) Additional code files may be needed
vb@130
    16
** if you want a wrapper to interface SQLite with your choice of programming
vb@130
    17
** language. The code for the "sqlite3" command-line shell is also in a
vb@130
    18
** separate file. This file contains only code for the core SQLite library.
vb@130
    19
*/
vb@130
    20
#define SQLITE_CORE 1
vb@130
    21
#define SQLITE_AMALGAMATION 1
vb@130
    22
#ifndef SQLITE_PRIVATE
vb@130
    23
# define SQLITE_PRIVATE static
vb@130
    24
#endif
dz@3192
    25
/************** Begin file ctime.c *******************************************/
dz@3192
    26
/*
dz@3192
    27
** 2010 February 23
dz@3192
    28
**
dz@3192
    29
** The author disclaims copyright to this source code.  In place of
dz@3192
    30
** a legal notice, here is a blessing:
dz@3192
    31
**
dz@3192
    32
**    May you do good and not evil.
dz@3192
    33
**    May you find forgiveness for yourself and forgive others.
dz@3192
    34
**    May you share freely, never taking more than you give.
dz@3192
    35
**
dz@3192
    36
*************************************************************************
dz@3192
    37
**
dz@3192
    38
** This file implements routines used to report what compile-time options
dz@3192
    39
** SQLite was built with.
dz@3192
    40
*/
dz@3192
    41
dz@3192
    42
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
dz@3192
    43
dz@3192
    44
/*
dz@3192
    45
** Include the configuration header output by 'configure' if we're using the
dz@3192
    46
** autoconf-based build
dz@3192
    47
*/
dz@3192
    48
#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
dz@3192
    49
#include "config.h"
dz@3192
    50
#define SQLITECONFIG_H 1
dz@3192
    51
#endif
dz@3192
    52
dz@3192
    53
/* These macros are provided to "stringify" the value of the define
dz@3192
    54
** for those options in which the value is meaningful. */
dz@3192
    55
#define CTIMEOPT_VAL_(opt) #opt
dz@3192
    56
#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
dz@3192
    57
dz@3192
    58
/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
dz@3192
    59
** option requires a separate macro because legal values contain a single
dz@3192
    60
** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
dz@3192
    61
#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
dz@3192
    62
#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
dz@3192
    63
dz@3192
    64
/*
dz@3192
    65
** An array of names of all compile-time options.  This array should 
dz@3192
    66
** be sorted A-Z.
dz@3192
    67
**
dz@3192
    68
** This array looks large, but in a typical installation actually uses
dz@3192
    69
** only a handful of compile-time options, so most times this array is usually
dz@3192
    70
** rather short and uses little memory space.
dz@3192
    71
*/
dz@3192
    72
static const char * const sqlite3azCompileOpt[] = {
dz@3192
    73
dz@3192
    74
/* 
dz@3192
    75
** BEGIN CODE GENERATED BY tool/mkctime.tcl 
dz@3192
    76
*/
dz@3192
    77
#if SQLITE_32BIT_ROWID
dz@3192
    78
  "32BIT_ROWID",
dz@3192
    79
#endif
dz@3192
    80
#if SQLITE_4_BYTE_ALIGNED_MALLOC
dz@3192
    81
  "4_BYTE_ALIGNED_MALLOC",
dz@3192
    82
#endif
dz@3192
    83
#if SQLITE_64BIT_STATS
dz@3192
    84
  "64BIT_STATS",
dz@3192
    85
#endif
dz@3192
    86
#if SQLITE_ALLOW_COVERING_INDEX_SCAN
dz@3192
    87
  "ALLOW_COVERING_INDEX_SCAN",
dz@3192
    88
#endif
dz@3192
    89
#if SQLITE_ALLOW_URI_AUTHORITY
dz@3192
    90
  "ALLOW_URI_AUTHORITY",
dz@3192
    91
#endif
dz@3192
    92
#ifdef SQLITE_BITMASK_TYPE
dz@3192
    93
  "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
dz@3192
    94
#endif
dz@3192
    95
#if SQLITE_BUG_COMPATIBLE_20160819
dz@3192
    96
  "BUG_COMPATIBLE_20160819",
dz@3192
    97
#endif
dz@3192
    98
#if SQLITE_CASE_SENSITIVE_LIKE
dz@3192
    99
  "CASE_SENSITIVE_LIKE",
dz@3192
   100
#endif
dz@3192
   101
#if SQLITE_CHECK_PAGES
dz@3192
   102
  "CHECK_PAGES",
dz@3192
   103
#endif
dz@3192
   104
#if defined(__clang__) && defined(__clang_major__)
dz@3192
   105
  "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
dz@3192
   106
                    CTIMEOPT_VAL(__clang_minor__) "."
dz@3192
   107
                    CTIMEOPT_VAL(__clang_patchlevel__),
dz@3192
   108
#elif defined(_MSC_VER)
dz@3192
   109
  "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
dz@3192
   110
#elif defined(__GNUC__) && defined(__VERSION__)
dz@3192
   111
  "COMPILER=gcc-" __VERSION__,
dz@3192
   112
#endif
dz@3192
   113
#if SQLITE_COVERAGE_TEST
dz@3192
   114
  "COVERAGE_TEST",
dz@3192
   115
#endif
dz@3192
   116
#if SQLITE_DEBUG
dz@3192
   117
  "DEBUG",
dz@3192
   118
#endif
dz@3192
   119
#if SQLITE_DEFAULT_AUTOMATIC_INDEX
dz@3192
   120
  "DEFAULT_AUTOMATIC_INDEX",
dz@3192
   121
#endif
dz@3192
   122
#if SQLITE_DEFAULT_AUTOVACUUM
dz@3192
   123
  "DEFAULT_AUTOVACUUM",
dz@3192
   124
#endif
dz@3192
   125
#ifdef SQLITE_DEFAULT_CACHE_SIZE
dz@3192
   126
  "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
dz@3192
   127
#endif
dz@3192
   128
#if SQLITE_DEFAULT_CKPTFULLFSYNC
dz@3192
   129
  "DEFAULT_CKPTFULLFSYNC",
dz@3192
   130
#endif
dz@3192
   131
#ifdef SQLITE_DEFAULT_FILE_FORMAT
dz@3192
   132
  "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
dz@3192
   133
#endif
dz@3192
   134
#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
dz@3192
   135
  "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
dz@3192
   136
#endif
dz@3192
   137
#if SQLITE_DEFAULT_FOREIGN_KEYS
dz@3192
   138
  "DEFAULT_FOREIGN_KEYS",
dz@3192
   139
#endif
dz@3192
   140
#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
dz@3192
   141
  "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
dz@3192
   142
#endif
dz@3192
   143
#ifdef SQLITE_DEFAULT_LOCKING_MODE
dz@3192
   144
  "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
dz@3192
   145
#endif
dz@3192
   146
#ifdef SQLITE_DEFAULT_LOOKASIDE
dz@3192
   147
  "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
dz@3192
   148
#endif
dz@3192
   149
#if SQLITE_DEFAULT_MEMSTATUS
dz@3192
   150
  "DEFAULT_MEMSTATUS",
dz@3192
   151
#endif
dz@3192
   152
#ifdef SQLITE_DEFAULT_MMAP_SIZE
dz@3192
   153
  "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
dz@3192
   154
#endif
dz@3192
   155
#ifdef SQLITE_DEFAULT_PAGE_SIZE
dz@3192
   156
  "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
dz@3192
   157
#endif
dz@3192
   158
#ifdef SQLITE_DEFAULT_PCACHE_INITSZ
dz@3192
   159
  "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
dz@3192
   160
#endif
dz@3192
   161
#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
dz@3192
   162
  "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
dz@3192
   163
#endif
dz@3192
   164
#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
dz@3192
   165
  "DEFAULT_RECURSIVE_TRIGGERS",
dz@3192
   166
#endif
dz@3192
   167
#ifdef SQLITE_DEFAULT_ROWEST
dz@3192
   168
  "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
dz@3192
   169
#endif
dz@3192
   170
#ifdef SQLITE_DEFAULT_SECTOR_SIZE
dz@3192
   171
  "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
dz@3192
   172
#endif
dz@3192
   173
#ifdef SQLITE_DEFAULT_SYNCHRONOUS
dz@3192
   174
  "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
dz@3192
   175
#endif
dz@3192
   176
#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
dz@3192
   177
  "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
dz@3192
   178
#endif
dz@3192
   179
#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
dz@3192
   180
  "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
dz@3192
   181
#endif
dz@3192
   182
#ifdef SQLITE_DEFAULT_WORKER_THREADS
dz@3192
   183
  "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
dz@3192
   184
#endif
dz@3192
   185
#if SQLITE_DIRECT_OVERFLOW_READ
dz@3192
   186
  "DIRECT_OVERFLOW_READ",
dz@3192
   187
#endif
dz@3192
   188
#if SQLITE_DISABLE_DIRSYNC
dz@3192
   189
  "DISABLE_DIRSYNC",
dz@3192
   190
#endif
dz@3192
   191
#if SQLITE_DISABLE_FTS3_UNICODE
dz@3192
   192
  "DISABLE_FTS3_UNICODE",
dz@3192
   193
#endif
dz@3192
   194
#if SQLITE_DISABLE_FTS4_DEFERRED
dz@3192
   195
  "DISABLE_FTS4_DEFERRED",
dz@3192
   196
#endif
dz@3192
   197
#if SQLITE_DISABLE_INTRINSIC
dz@3192
   198
  "DISABLE_INTRINSIC",
dz@3192
   199
#endif
dz@3192
   200
#if SQLITE_DISABLE_LFS
dz@3192
   201
  "DISABLE_LFS",
dz@3192
   202
#endif
dz@3192
   203
#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
dz@3192
   204
  "DISABLE_PAGECACHE_OVERFLOW_STATS",
dz@3192
   205
#endif
dz@3192
   206
#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT
dz@3192
   207
  "DISABLE_SKIPAHEAD_DISTINCT",
dz@3192
   208
#endif
dz@3192
   209
#ifdef SQLITE_ENABLE_8_3_NAMES
dz@3192
   210
  "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
dz@3192
   211
#endif
dz@3192
   212
#if SQLITE_ENABLE_API_ARMOR
dz@3192
   213
  "ENABLE_API_ARMOR",
dz@3192
   214
#endif
dz@3192
   215
#if SQLITE_ENABLE_ATOMIC_WRITE
dz@3192
   216
  "ENABLE_ATOMIC_WRITE",
dz@3192
   217
#endif
dz@3192
   218
#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE
dz@3192
   219
  "ENABLE_BATCH_ATOMIC_WRITE",
dz@3192
   220
#endif
dz@3192
   221
#if SQLITE_ENABLE_CEROD
dz@3192
   222
  "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
dz@3192
   223
#endif
dz@3192
   224
#if SQLITE_ENABLE_COLUMN_METADATA
dz@3192
   225
  "ENABLE_COLUMN_METADATA",
dz@3192
   226
#endif
dz@3192
   227
#if SQLITE_ENABLE_COLUMN_USED_MASK
dz@3192
   228
  "ENABLE_COLUMN_USED_MASK",
dz@3192
   229
#endif
dz@3192
   230
#if SQLITE_ENABLE_COSTMULT
dz@3192
   231
  "ENABLE_COSTMULT",
dz@3192
   232
#endif
dz@3192
   233
#if SQLITE_ENABLE_CURSOR_HINTS
dz@3192
   234
  "ENABLE_CURSOR_HINTS",
dz@3192
   235
#endif
dz@3192
   236
#if SQLITE_ENABLE_DBSTAT_VTAB
dz@3192
   237
  "ENABLE_DBSTAT_VTAB",
dz@3192
   238
#endif
dz@3192
   239
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
dz@3192
   240
  "ENABLE_EXPENSIVE_ASSERT",
dz@3192
   241
#endif
dz@3192
   242
#if SQLITE_ENABLE_FTS1
dz@3192
   243
  "ENABLE_FTS1",
dz@3192
   244
#endif
dz@3192
   245
#if SQLITE_ENABLE_FTS2
dz@3192
   246
  "ENABLE_FTS2",
dz@3192
   247
#endif
dz@3192
   248
#if SQLITE_ENABLE_FTS3
dz@3192
   249
  "ENABLE_FTS3",
dz@3192
   250
#endif
dz@3192
   251
#if SQLITE_ENABLE_FTS3_PARENTHESIS
dz@3192
   252
  "ENABLE_FTS3_PARENTHESIS",
dz@3192
   253
#endif
dz@3192
   254
#if SQLITE_ENABLE_FTS3_TOKENIZER
dz@3192
   255
  "ENABLE_FTS3_TOKENIZER",
dz@3192
   256
#endif
dz@3192
   257
#if SQLITE_ENABLE_FTS4
dz@3192
   258
  "ENABLE_FTS4",
dz@3192
   259
#endif
dz@3192
   260
#if SQLITE_ENABLE_FTS5
dz@3192
   261
  "ENABLE_FTS5",
dz@3192
   262
#endif
dz@3192
   263
#if SQLITE_ENABLE_GEOPOLY
dz@3192
   264
  "ENABLE_GEOPOLY",
dz@3192
   265
#endif
dz@3192
   266
#if SQLITE_ENABLE_HIDDEN_COLUMNS
dz@3192
   267
  "ENABLE_HIDDEN_COLUMNS",
dz@3192
   268
#endif
dz@3192
   269
#if SQLITE_ENABLE_ICU
dz@3192
   270
  "ENABLE_ICU",
dz@3192
   271
#endif
dz@3192
   272
#if SQLITE_ENABLE_IOTRACE
dz@3192
   273
  "ENABLE_IOTRACE",
dz@3192
   274
#endif
dz@3192
   275
#if SQLITE_ENABLE_JSON1
dz@3192
   276
  "ENABLE_JSON1",
dz@3192
   277
#endif
dz@3192
   278
#if SQLITE_ENABLE_LOAD_EXTENSION
dz@3192
   279
  "ENABLE_LOAD_EXTENSION",
dz@3192
   280
#endif
dz@3192
   281
#ifdef SQLITE_ENABLE_LOCKING_STYLE
dz@3192
   282
  "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
dz@3192
   283
#endif
dz@3192
   284
#if SQLITE_ENABLE_MEMORY_MANAGEMENT
dz@3192
   285
  "ENABLE_MEMORY_MANAGEMENT",
dz@3192
   286
#endif
dz@3192
   287
#if SQLITE_ENABLE_MEMSYS3
dz@3192
   288
  "ENABLE_MEMSYS3",
dz@3192
   289
#endif
dz@3192
   290
#if SQLITE_ENABLE_MEMSYS5
dz@3192
   291
  "ENABLE_MEMSYS5",
dz@3192
   292
#endif
dz@3192
   293
#if SQLITE_ENABLE_MULTIPLEX
dz@3192
   294
  "ENABLE_MULTIPLEX",
dz@3192
   295
#endif
dz@3192
   296
#if SQLITE_ENABLE_NORMALIZE
dz@3192
   297
  "ENABLE_NORMALIZE",
dz@3192
   298
#endif
dz@3192
   299
#if SQLITE_ENABLE_NULL_TRIM
dz@3192
   300
  "ENABLE_NULL_TRIM",
dz@3192
   301
#endif
dz@3192
   302
#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
dz@3192
   303
  "ENABLE_OVERSIZE_CELL_CHECK",
dz@3192
   304
#endif
dz@3192
   305
#if SQLITE_ENABLE_PREUPDATE_HOOK
dz@3192
   306
  "ENABLE_PREUPDATE_HOOK",
dz@3192
   307
#endif
dz@3192
   308
#if SQLITE_ENABLE_QPSG
dz@3192
   309
  "ENABLE_QPSG",
dz@3192
   310
#endif
dz@3192
   311
#if SQLITE_ENABLE_RBU
dz@3192
   312
  "ENABLE_RBU",
dz@3192
   313
#endif
dz@3192
   314
#if SQLITE_ENABLE_RTREE
dz@3192
   315
  "ENABLE_RTREE",
dz@3192
   316
#endif
dz@3192
   317
#if SQLITE_ENABLE_SELECTTRACE
dz@3192
   318
  "ENABLE_SELECTTRACE",
dz@3192
   319
#endif
dz@3192
   320
#if SQLITE_ENABLE_SESSION
dz@3192
   321
  "ENABLE_SESSION",
dz@3192
   322
#endif
dz@3192
   323
#if SQLITE_ENABLE_SNAPSHOT
dz@3192
   324
  "ENABLE_SNAPSHOT",
dz@3192
   325
#endif
dz@3192
   326
#if SQLITE_ENABLE_SORTER_REFERENCES
dz@3192
   327
  "ENABLE_SORTER_REFERENCES",
dz@3192
   328
#endif
dz@3192
   329
#if SQLITE_ENABLE_SQLLOG
dz@3192
   330
  "ENABLE_SQLLOG",
dz@3192
   331
#endif
dz@3192
   332
#if defined(SQLITE_ENABLE_STAT4)
dz@3192
   333
  "ENABLE_STAT4",
dz@3192
   334
#elif defined(SQLITE_ENABLE_STAT3)
dz@3192
   335
  "ENABLE_STAT3",
dz@3192
   336
#endif
dz@3192
   337
#if SQLITE_ENABLE_STMTVTAB
dz@3192
   338
  "ENABLE_STMTVTAB",
dz@3192
   339
#endif
dz@3192
   340
#if SQLITE_ENABLE_STMT_SCANSTATUS
dz@3192
   341
  "ENABLE_STMT_SCANSTATUS",
dz@3192
   342
#endif
dz@3192
   343
#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
dz@3192
   344
  "ENABLE_UNKNOWN_SQL_FUNCTION",
dz@3192
   345
#endif
dz@3192
   346
#if SQLITE_ENABLE_UNLOCK_NOTIFY
dz@3192
   347
  "ENABLE_UNLOCK_NOTIFY",
dz@3192
   348
#endif
dz@3192
   349
#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
dz@3192
   350
  "ENABLE_UPDATE_DELETE_LIMIT",
dz@3192
   351
#endif
dz@3192
   352
#if SQLITE_ENABLE_URI_00_ERROR
dz@3192
   353
  "ENABLE_URI_00_ERROR",
dz@3192
   354
#endif
dz@3192
   355
#if SQLITE_ENABLE_VFSTRACE
dz@3192
   356
  "ENABLE_VFSTRACE",
dz@3192
   357
#endif
dz@3192
   358
#if SQLITE_ENABLE_WHERETRACE
dz@3192
   359
  "ENABLE_WHERETRACE",
dz@3192
   360
#endif
dz@3192
   361
#if SQLITE_ENABLE_ZIPVFS
dz@3192
   362
  "ENABLE_ZIPVFS",
dz@3192
   363
#endif
dz@3192
   364
#if SQLITE_EXPLAIN_ESTIMATED_ROWS
dz@3192
   365
  "EXPLAIN_ESTIMATED_ROWS",
dz@3192
   366
#endif
dz@3192
   367
#if SQLITE_EXTRA_IFNULLROW
dz@3192
   368
  "EXTRA_IFNULLROW",
dz@3192
   369
#endif
dz@3192
   370
#ifdef SQLITE_EXTRA_INIT
dz@3192
   371
  "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
dz@3192
   372
#endif
dz@3192
   373
#ifdef SQLITE_EXTRA_SHUTDOWN
dz@3192
   374
  "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
dz@3192
   375
#endif
dz@3192
   376
#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
dz@3192
   377
  "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
dz@3192
   378
#endif
dz@3192
   379
#if SQLITE_FTS5_ENABLE_TEST_MI
dz@3192
   380
  "FTS5_ENABLE_TEST_MI",
dz@3192
   381
#endif
dz@3192
   382
#if SQLITE_FTS5_NO_WITHOUT_ROWID
dz@3192
   383
  "FTS5_NO_WITHOUT_ROWID",
dz@3192
   384
#endif
dz@3192
   385
#if SQLITE_HAS_CODEC
dz@3192
   386
  "HAS_CODEC",
dz@3192
   387
#endif
dz@3192
   388
#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
dz@3192
   389
  "HAVE_ISNAN",
dz@3192
   390
#endif
dz@3192
   391
#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
dz@3192
   392
  "HOMEGROWN_RECURSIVE_MUTEX",
dz@3192
   393
#endif
dz@3192
   394
#if SQLITE_IGNORE_AFP_LOCK_ERRORS
dz@3192
   395
  "IGNORE_AFP_LOCK_ERRORS",
dz@3192
   396
#endif
dz@3192
   397
#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
dz@3192
   398
  "IGNORE_FLOCK_LOCK_ERRORS",
dz@3192
   399
#endif
dz@3192
   400
#if SQLITE_INLINE_MEMCPY
dz@3192
   401
  "INLINE_MEMCPY",
dz@3192
   402
#endif
dz@3192
   403
#if SQLITE_INT64_TYPE
dz@3192
   404
  "INT64_TYPE",
dz@3192
   405
#endif
dz@3192
   406
#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
dz@3192
   407
  "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
dz@3192
   408
#endif
dz@3192
   409
#if SQLITE_LIKE_DOESNT_MATCH_BLOBS
dz@3192
   410
  "LIKE_DOESNT_MATCH_BLOBS",
dz@3192
   411
#endif
dz@3192
   412
#if SQLITE_LOCK_TRACE
dz@3192
   413
  "LOCK_TRACE",
dz@3192
   414
#endif
dz@3192
   415
#if SQLITE_LOG_CACHE_SPILL
dz@3192
   416
  "LOG_CACHE_SPILL",
dz@3192
   417
#endif
dz@3192
   418
#ifdef SQLITE_MALLOC_SOFT_LIMIT
dz@3192
   419
  "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
dz@3192
   420
#endif
dz@3192
   421
#ifdef SQLITE_MAX_ATTACHED
dz@3192
   422
  "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
dz@3192
   423
#endif
dz@3192
   424
#ifdef SQLITE_MAX_COLUMN
dz@3192
   425
  "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
dz@3192
   426
#endif
dz@3192
   427
#ifdef SQLITE_MAX_COMPOUND_SELECT
dz@3192
   428
  "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
dz@3192
   429
#endif
dz@3192
   430
#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
dz@3192
   431
  "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
dz@3192
   432
#endif
dz@3192
   433
#ifdef SQLITE_MAX_EXPR_DEPTH
dz@3192
   434
  "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
dz@3192
   435
#endif
dz@3192
   436
#ifdef SQLITE_MAX_FUNCTION_ARG
dz@3192
   437
  "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
dz@3192
   438
#endif
dz@3192
   439
#ifdef SQLITE_MAX_LENGTH
dz@3192
   440
  "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
dz@3192
   441
#endif
dz@3192
   442
#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
dz@3192
   443
  "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
dz@3192
   444
#endif
dz@3192
   445
#ifdef SQLITE_MAX_MEMORY
dz@3192
   446
  "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
dz@3192
   447
#endif
dz@3192
   448
#ifdef SQLITE_MAX_MMAP_SIZE
dz@3192
   449
  "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
dz@3192
   450
#endif
dz@3192
   451
#ifdef SQLITE_MAX_MMAP_SIZE_
dz@3192
   452
  "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
dz@3192
   453
#endif
dz@3192
   454
#ifdef SQLITE_MAX_PAGE_COUNT
dz@3192
   455
  "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
dz@3192
   456
#endif
dz@3192
   457
#ifdef SQLITE_MAX_PAGE_SIZE
dz@3192
   458
  "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
dz@3192
   459
#endif
dz@3192
   460
#ifdef SQLITE_MAX_SCHEMA_RETRY
dz@3192
   461
  "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
dz@3192
   462
#endif
dz@3192
   463
#ifdef SQLITE_MAX_SQL_LENGTH
dz@3192
   464
  "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
dz@3192
   465
#endif
dz@3192
   466
#ifdef SQLITE_MAX_TRIGGER_DEPTH
dz@3192
   467
  "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
dz@3192
   468
#endif
dz@3192
   469
#ifdef SQLITE_MAX_VARIABLE_NUMBER
dz@3192
   470
  "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
dz@3192
   471
#endif
dz@3192
   472
#ifdef SQLITE_MAX_VDBE_OP
dz@3192
   473
  "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
dz@3192
   474
#endif
dz@3192
   475
#ifdef SQLITE_MAX_WORKER_THREADS
dz@3192
   476
  "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
dz@3192
   477
#endif
dz@3192
   478
#if SQLITE_MEMDEBUG
dz@3192
   479
  "MEMDEBUG",
dz@3192
   480
#endif
dz@3192
   481
#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
dz@3192
   482
  "MIXED_ENDIAN_64BIT_FLOAT",
dz@3192
   483
#endif
dz@3192
   484
#if SQLITE_MMAP_READWRITE
dz@3192
   485
  "MMAP_READWRITE",
dz@3192
   486
#endif
dz@3192
   487
#if SQLITE_MUTEX_NOOP
dz@3192
   488
  "MUTEX_NOOP",
dz@3192
   489
#endif
dz@3192
   490
#if SQLITE_MUTEX_NREF
dz@3192
   491
  "MUTEX_NREF",
dz@3192
   492
#endif
dz@3192
   493
#if SQLITE_MUTEX_OMIT
dz@3192
   494
  "MUTEX_OMIT",
dz@3192
   495
#endif
dz@3192
   496
#if SQLITE_MUTEX_PTHREADS
dz@3192
   497
  "MUTEX_PTHREADS",
dz@3192
   498
#endif
dz@3192
   499
#if SQLITE_MUTEX_W32
dz@3192
   500
  "MUTEX_W32",
dz@3192
   501
#endif
dz@3192
   502
#if SQLITE_NEED_ERR_NAME
dz@3192
   503
  "NEED_ERR_NAME",
dz@3192
   504
#endif
dz@3192
   505
#if SQLITE_NOINLINE
dz@3192
   506
  "NOINLINE",
dz@3192
   507
#endif
dz@3192
   508
#if SQLITE_NO_SYNC
dz@3192
   509
  "NO_SYNC",
dz@3192
   510
#endif
dz@3192
   511
#if SQLITE_OMIT_ALTERTABLE
dz@3192
   512
  "OMIT_ALTERTABLE",
dz@3192
   513
#endif
dz@3192
   514
#if SQLITE_OMIT_ANALYZE
dz@3192
   515
  "OMIT_ANALYZE",
dz@3192
   516
#endif
dz@3192
   517
#if SQLITE_OMIT_ATTACH
dz@3192
   518
  "OMIT_ATTACH",
dz@3192
   519
#endif
dz@3192
   520
#if SQLITE_OMIT_AUTHORIZATION
dz@3192
   521
  "OMIT_AUTHORIZATION",
dz@3192
   522
#endif
dz@3192
   523
#if SQLITE_OMIT_AUTOINCREMENT
dz@3192
   524
  "OMIT_AUTOINCREMENT",
dz@3192
   525
#endif
dz@3192
   526
#if SQLITE_OMIT_AUTOINIT
dz@3192
   527
  "OMIT_AUTOINIT",
dz@3192
   528
#endif
dz@3192
   529
#if SQLITE_OMIT_AUTOMATIC_INDEX
dz@3192
   530
  "OMIT_AUTOMATIC_INDEX",
dz@3192
   531
#endif
dz@3192
   532
#if SQLITE_OMIT_AUTORESET
dz@3192
   533
  "OMIT_AUTORESET",
dz@3192
   534
#endif
dz@3192
   535
#if SQLITE_OMIT_AUTOVACUUM
dz@3192
   536
  "OMIT_AUTOVACUUM",
dz@3192
   537
#endif
dz@3192
   538
#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
dz@3192
   539
  "OMIT_BETWEEN_OPTIMIZATION",
dz@3192
   540
#endif
dz@3192
   541
#if SQLITE_OMIT_BLOB_LITERAL
dz@3192
   542
  "OMIT_BLOB_LITERAL",
dz@3192
   543
#endif
dz@3192
   544
#if SQLITE_OMIT_BTREECOUNT
dz@3192
   545
  "OMIT_BTREECOUNT",
dz@3192
   546
#endif
dz@3192
   547
#if SQLITE_OMIT_CAST
dz@3192
   548
  "OMIT_CAST",
dz@3192
   549
#endif
dz@3192
   550
#if SQLITE_OMIT_CHECK
dz@3192
   551
  "OMIT_CHECK",
dz@3192
   552
#endif
dz@3192
   553
#if SQLITE_OMIT_COMPLETE
dz@3192
   554
  "OMIT_COMPLETE",
dz@3192
   555
#endif
dz@3192
   556
#if SQLITE_OMIT_COMPOUND_SELECT
dz@3192
   557
  "OMIT_COMPOUND_SELECT",
dz@3192
   558
#endif
dz@3192
   559
#if SQLITE_OMIT_CONFLICT_CLAUSE
dz@3192
   560
  "OMIT_CONFLICT_CLAUSE",
dz@3192
   561
#endif
dz@3192
   562
#if SQLITE_OMIT_CTE
dz@3192
   563
  "OMIT_CTE",
dz@3192
   564
#endif
dz@3192
   565
#if SQLITE_OMIT_DATETIME_FUNCS
dz@3192
   566
  "OMIT_DATETIME_FUNCS",
dz@3192
   567
#endif
dz@3192
   568
#if SQLITE_OMIT_DECLTYPE
dz@3192
   569
  "OMIT_DECLTYPE",
dz@3192
   570
#endif
dz@3192
   571
#if SQLITE_OMIT_DEPRECATED
dz@3192
   572
  "OMIT_DEPRECATED",
dz@3192
   573
#endif
dz@3192
   574
#if SQLITE_OMIT_DISKIO
dz@3192
   575
  "OMIT_DISKIO",
dz@3192
   576
#endif
dz@3192
   577
#if SQLITE_OMIT_EXPLAIN
dz@3192
   578
  "OMIT_EXPLAIN",
dz@3192
   579
#endif
dz@3192
   580
#if SQLITE_OMIT_FLAG_PRAGMAS
dz@3192
   581
  "OMIT_FLAG_PRAGMAS",
dz@3192
   582
#endif
dz@3192
   583
#if SQLITE_OMIT_FLOATING_POINT
dz@3192
   584
  "OMIT_FLOATING_POINT",
dz@3192
   585
#endif
dz@3192
   586
#if SQLITE_OMIT_FOREIGN_KEY
dz@3192
   587
  "OMIT_FOREIGN_KEY",
dz@3192
   588
#endif
dz@3192
   589
#if SQLITE_OMIT_GET_TABLE
dz@3192
   590
  "OMIT_GET_TABLE",
dz@3192
   591
#endif
dz@3192
   592
#if SQLITE_OMIT_HEX_INTEGER
dz@3192
   593
  "OMIT_HEX_INTEGER",
dz@3192
   594
#endif
dz@3192
   595
#if SQLITE_OMIT_INCRBLOB
dz@3192
   596
  "OMIT_INCRBLOB",
dz@3192
   597
#endif
dz@3192
   598
#if SQLITE_OMIT_INTEGRITY_CHECK
dz@3192
   599
  "OMIT_INTEGRITY_CHECK",
dz@3192
   600
#endif
dz@3192
   601
#if SQLITE_OMIT_LIKE_OPTIMIZATION
dz@3192
   602
  "OMIT_LIKE_OPTIMIZATION",
dz@3192
   603
#endif
dz@3192
   604
#if SQLITE_OMIT_LOAD_EXTENSION
dz@3192
   605
  "OMIT_LOAD_EXTENSION",
dz@3192
   606
#endif
dz@3192
   607
#if SQLITE_OMIT_LOCALTIME
dz@3192
   608
  "OMIT_LOCALTIME",
dz@3192
   609
#endif
dz@3192
   610
#if SQLITE_OMIT_LOOKASIDE
dz@3192
   611
  "OMIT_LOOKASIDE",
dz@3192
   612
#endif
dz@3192
   613
#if SQLITE_OMIT_MEMORYDB
dz@3192
   614
  "OMIT_MEMORYDB",
dz@3192
   615
#endif
dz@3192
   616
#if SQLITE_OMIT_OR_OPTIMIZATION
dz@3192
   617
  "OMIT_OR_OPTIMIZATION",
dz@3192
   618
#endif
dz@3192
   619
#if SQLITE_OMIT_PAGER_PRAGMAS
dz@3192
   620
  "OMIT_PAGER_PRAGMAS",
dz@3192
   621
#endif
dz@3192
   622
#if SQLITE_OMIT_PARSER_TRACE
dz@3192
   623
  "OMIT_PARSER_TRACE",
dz@3192
   624
#endif
dz@3192
   625
#if SQLITE_OMIT_POPEN
dz@3192
   626
  "OMIT_POPEN",
dz@3192
   627
#endif
dz@3192
   628
#if SQLITE_OMIT_PRAGMA
dz@3192
   629
  "OMIT_PRAGMA",
dz@3192
   630
#endif
dz@3192
   631
#if SQLITE_OMIT_PROGRESS_CALLBACK
dz@3192
   632
  "OMIT_PROGRESS_CALLBACK",
dz@3192
   633
#endif
dz@3192
   634
#if SQLITE_OMIT_QUICKBALANCE
dz@3192
   635
  "OMIT_QUICKBALANCE",
dz@3192
   636
#endif
dz@3192
   637
#if SQLITE_OMIT_REINDEX
dz@3192
   638
  "OMIT_REINDEX",
dz@3192
   639
#endif
dz@3192
   640
#if SQLITE_OMIT_SCHEMA_PRAGMAS
dz@3192
   641
  "OMIT_SCHEMA_PRAGMAS",
dz@3192
   642
#endif
dz@3192
   643
#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
dz@3192
   644
  "OMIT_SCHEMA_VERSION_PRAGMAS",
dz@3192
   645
#endif
dz@3192
   646
#if SQLITE_OMIT_SHARED_CACHE
dz@3192
   647
  "OMIT_SHARED_CACHE",
dz@3192
   648
#endif
dz@3192
   649
#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES
dz@3192
   650
  "OMIT_SHUTDOWN_DIRECTORIES",
dz@3192
   651
#endif
dz@3192
   652
#if SQLITE_OMIT_SUBQUERY
dz@3192
   653
  "OMIT_SUBQUERY",
dz@3192
   654
#endif
dz@3192
   655
#if SQLITE_OMIT_TCL_VARIABLE
dz@3192
   656
  "OMIT_TCL_VARIABLE",
dz@3192
   657
#endif
dz@3192
   658
#if SQLITE_OMIT_TEMPDB
dz@3192
   659
  "OMIT_TEMPDB",
dz@3192
   660
#endif
dz@3192
   661
#if SQLITE_OMIT_TEST_CONTROL
dz@3192
   662
  "OMIT_TEST_CONTROL",
dz@3192
   663
#endif
dz@3192
   664
#if SQLITE_OMIT_TRACE
dz@3192
   665
  "OMIT_TRACE",
dz@3192
   666
#endif
dz@3192
   667
#if SQLITE_OMIT_TRIGGER
dz@3192
   668
  "OMIT_TRIGGER",
dz@3192
   669
#endif
dz@3192
   670
#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
dz@3192
   671
  "OMIT_TRUNCATE_OPTIMIZATION",
dz@3192
   672
#endif
dz@3192
   673
#if SQLITE_OMIT_UTF16
dz@3192
   674
  "OMIT_UTF16",
dz@3192
   675
#endif
dz@3192
   676
#if SQLITE_OMIT_VACUUM
dz@3192
   677
  "OMIT_VACUUM",
dz@3192
   678
#endif
dz@3192
   679
#if SQLITE_OMIT_VIEW
dz@3192
   680
  "OMIT_VIEW",
dz@3192
   681
#endif
dz@3192
   682
#if SQLITE_OMIT_VIRTUALTABLE
dz@3192
   683
  "OMIT_VIRTUALTABLE",
dz@3192
   684
#endif
dz@3192
   685
#if SQLITE_OMIT_WAL
dz@3192
   686
  "OMIT_WAL",
dz@3192
   687
#endif
dz@3192
   688
#if SQLITE_OMIT_WSD
dz@3192
   689
  "OMIT_WSD",
dz@3192
   690
#endif
dz@3192
   691
#if SQLITE_OMIT_XFER_OPT
dz@3192
   692
  "OMIT_XFER_OPT",
dz@3192
   693
#endif
dz@3192
   694
#if SQLITE_PCACHE_SEPARATE_HEADER
dz@3192
   695
  "PCACHE_SEPARATE_HEADER",
dz@3192
   696
#endif
dz@3192
   697
#if SQLITE_PERFORMANCE_TRACE
dz@3192
   698
  "PERFORMANCE_TRACE",
dz@3192
   699
#endif
dz@3192
   700
#if SQLITE_POWERSAFE_OVERWRITE
dz@3192
   701
  "POWERSAFE_OVERWRITE",
dz@3192
   702
#endif
dz@3192
   703
#if SQLITE_PREFER_PROXY_LOCKING
dz@3192
   704
  "PREFER_PROXY_LOCKING",
dz@3192
   705
#endif
dz@3192
   706
#if SQLITE_PROXY_DEBUG
dz@3192
   707
  "PROXY_DEBUG",
dz@3192
   708
#endif
dz@3192
   709
#if SQLITE_REVERSE_UNORDERED_SELECTS
dz@3192
   710
  "REVERSE_UNORDERED_SELECTS",
dz@3192
   711
#endif
dz@3192
   712
#if SQLITE_RTREE_INT_ONLY
dz@3192
   713
  "RTREE_INT_ONLY",
dz@3192
   714
#endif
dz@3192
   715
#if SQLITE_SECURE_DELETE
dz@3192
   716
  "SECURE_DELETE",
dz@3192
   717
#endif
dz@3192
   718
#if SQLITE_SMALL_STACK
dz@3192
   719
  "SMALL_STACK",
dz@3192
   720
#endif
dz@3192
   721
#ifdef SQLITE_SORTER_PMASZ
dz@3192
   722
  "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
dz@3192
   723
#endif
dz@3192
   724
#if SQLITE_SOUNDEX
dz@3192
   725
  "SOUNDEX",
dz@3192
   726
#endif
dz@3192
   727
#ifdef SQLITE_STAT4_SAMPLES
dz@3192
   728
  "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
dz@3192
   729
#endif
dz@3192
   730
#ifdef SQLITE_STMTJRNL_SPILL
dz@3192
   731
  "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
dz@3192
   732
#endif
dz@3192
   733
#if SQLITE_SUBSTR_COMPATIBILITY
dz@3192
   734
  "SUBSTR_COMPATIBILITY",
dz@3192
   735
#endif
dz@3192
   736
#if SQLITE_SYSTEM_MALLOC
dz@3192
   737
  "SYSTEM_MALLOC",
dz@3192
   738
#endif
dz@3192
   739
#if SQLITE_TCL
dz@3192
   740
  "TCL",
dz@3192
   741
#endif
dz@3192
   742
#ifdef SQLITE_TEMP_STORE
dz@3192
   743
  "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
dz@3192
   744
#endif
dz@3192
   745
#if SQLITE_TEST
dz@3192
   746
  "TEST",
dz@3192
   747
#endif
dz@3192
   748
#if defined(SQLITE_THREADSAFE)
dz@3192
   749
  "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
dz@3192
   750
#elif defined(THREADSAFE)
dz@3192
   751
  "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
dz@3192
   752
#else
dz@3192
   753
  "THREADSAFE=1",
dz@3192
   754
#endif
dz@3192
   755
#if SQLITE_UNLINK_AFTER_CLOSE
dz@3192
   756
  "UNLINK_AFTER_CLOSE",
dz@3192
   757
#endif
dz@3192
   758
#if SQLITE_UNTESTABLE
dz@3192
   759
  "UNTESTABLE",
dz@3192
   760
#endif
dz@3192
   761
#if SQLITE_USER_AUTHENTICATION
dz@3192
   762
  "USER_AUTHENTICATION",
dz@3192
   763
#endif
dz@3192
   764
#if SQLITE_USE_ALLOCA
dz@3192
   765
  "USE_ALLOCA",
dz@3192
   766
#endif
dz@3192
   767
#if SQLITE_USE_FCNTL_TRACE
dz@3192
   768
  "USE_FCNTL_TRACE",
dz@3192
   769
#endif
dz@3192
   770
#if SQLITE_USE_URI
dz@3192
   771
  "USE_URI",
dz@3192
   772
#endif
dz@3192
   773
#if SQLITE_VDBE_COVERAGE
dz@3192
   774
  "VDBE_COVERAGE",
dz@3192
   775
#endif
dz@3192
   776
#if SQLITE_WIN32_MALLOC
dz@3192
   777
  "WIN32_MALLOC",
dz@3192
   778
#endif
dz@3192
   779
#if SQLITE_ZERO_MALLOC
dz@3192
   780
  "ZERO_MALLOC",
dz@3192
   781
#endif
dz@3192
   782
/* 
dz@3192
   783
** END CODE GENERATED BY tool/mkctime.tcl 
dz@3192
   784
*/
dz@3192
   785
};
dz@3192
   786
dz@3192
   787
SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
dz@3192
   788
  *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
dz@3192
   789
  return (const char**)sqlite3azCompileOpt;
dz@3192
   790
}
dz@3192
   791
dz@3192
   792
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
dz@3192
   793
dz@3192
   794
/************** End of ctime.c ***********************************************/
vb@130
   795
/************** Begin file sqliteInt.h ***************************************/
vb@130
   796
/*
vb@130
   797
** 2001 September 15
vb@130
   798
**
vb@130
   799
** The author disclaims copyright to this source code.  In place of
vb@130
   800
** a legal notice, here is a blessing:
vb@130
   801
**
vb@130
   802
**    May you do good and not evil.
vb@130
   803
**    May you find forgiveness for yourself and forgive others.
vb@130
   804
**    May you share freely, never taking more than you give.
vb@130
   805
**
vb@130
   806
*************************************************************************
vb@130
   807
** Internal interface definitions for SQLite.
vb@130
   808
**
vb@130
   809
*/
edouard@1912
   810
#ifndef SQLITEINT_H
edouard@1912
   811
#define SQLITEINT_H
vb@130
   812
vb@716
   813
/* Special Comments:
vb@716
   814
**
vb@716
   815
** Some comments have special meaning to the tools that measure test
vb@716
   816
** coverage:
vb@716
   817
**
vb@716
   818
**    NO_TEST                     - The branches on this line are not
vb@716
   819
**                                  measured by branch coverage.  This is
vb@716
   820
**                                  used on lines of code that actually
vb@716
   821
**                                  implement parts of coverage testing.
vb@716
   822
**
vb@716
   823
**    OPTIMIZATION-IF-TRUE        - This branch is allowed to alway be false
vb@716
   824
**                                  and the correct answer is still obtained,
vb@716
   825
**                                  though perhaps more slowly.
vb@716
   826
**
vb@716
   827
**    OPTIMIZATION-IF-FALSE       - This branch is allowed to alway be true
vb@716
   828
**                                  and the correct answer is still obtained,
vb@716
   829
**                                  though perhaps more slowly.
vb@716
   830
**
vb@716
   831
**    PREVENTS-HARMLESS-OVERREAD  - This branch prevents a buffer overread
vb@716
   832
**                                  that would be harmless and undetectable
vb@716
   833
**                                  if it did occur.  
vb@716
   834
**
vb@716
   835
** In all cases, the special comment must be enclosed in the usual
vb@716
   836
** slash-asterisk...asterisk-slash comment marks, with no spaces between the 
vb@716
   837
** asterisks and the comment text.
vb@716
   838
*/
vb@716
   839
vb@716
   840
/*
edouard@1912
   841
** Make sure the Tcl calling convention macro is defined.  This macro is
edouard@1912
   842
** only used by test code and Tcl integration code.
edouard@1912
   843
*/
edouard@1912
   844
#ifndef SQLITE_TCLAPI
edouard@1912
   845
#  define SQLITE_TCLAPI
edouard@1912
   846
#endif
edouard@1912
   847
edouard@1912
   848
/*
Edouard@491
   849
** Include the header file used to customize the compiler options for MSVC.
Edouard@491
   850
** This should be done first so that it can successfully prevent spurious
Edouard@491
   851
** compiler warnings due to subsequent content in this file and other files
Edouard@491
   852
** that are included by this file.
Edouard@491
   853
*/
Edouard@491
   854
/************** Include msvc.h in the middle of sqliteInt.h ******************/
Edouard@491
   855
/************** Begin file msvc.h ********************************************/
Edouard@491
   856
/*
Edouard@491
   857
** 2015 January 12
Edouard@491
   858
**
Edouard@491
   859
** The author disclaims copyright to this source code.  In place of
Edouard@491
   860
** a legal notice, here is a blessing:
Edouard@491
   861
**
Edouard@491
   862
**    May you do good and not evil.
Edouard@491
   863
**    May you find forgiveness for yourself and forgive others.
Edouard@491
   864
**    May you share freely, never taking more than you give.
Edouard@491
   865
**
Edouard@491
   866
******************************************************************************
Edouard@491
   867
**
Edouard@491
   868
** This file contains code that is specific to MSVC.
Edouard@491
   869
*/
edouard@1912
   870
#ifndef SQLITE_MSVC_H
edouard@1912
   871
#define SQLITE_MSVC_H
Edouard@491
   872
Edouard@491
   873
#if defined(_MSC_VER)
Edouard@491
   874
#pragma warning(disable : 4054)
Edouard@491
   875
#pragma warning(disable : 4055)
Edouard@491
   876
#pragma warning(disable : 4100)
Edouard@491
   877
#pragma warning(disable : 4127)
Edouard@491
   878
#pragma warning(disable : 4130)
Edouard@491
   879
#pragma warning(disable : 4152)
Edouard@491
   880
#pragma warning(disable : 4189)
Edouard@491
   881
#pragma warning(disable : 4206)
Edouard@491
   882
#pragma warning(disable : 4210)
Edouard@491
   883
#pragma warning(disable : 4232)
Edouard@491
   884
#pragma warning(disable : 4244)
Edouard@491
   885
#pragma warning(disable : 4305)
Edouard@491
   886
#pragma warning(disable : 4306)
Edouard@491
   887
#pragma warning(disable : 4702)
Edouard@491
   888
#pragma warning(disable : 4706)
Edouard@491
   889
#endif /* defined(_MSC_VER) */
Edouard@491
   890
edouard@1912
   891
#endif /* SQLITE_MSVC_H */
Edouard@491
   892
Edouard@491
   893
/************** End of msvc.h ************************************************/
Edouard@491
   894
/************** Continuing where we left off in sqliteInt.h ******************/
Edouard@491
   895
Edouard@491
   896
/*
Edouard@491
   897
** Special setup for VxWorks
Edouard@491
   898
*/
Edouard@491
   899
/************** Include vxworks.h in the middle of sqliteInt.h ***************/
Edouard@491
   900
/************** Begin file vxworks.h *****************************************/
Edouard@491
   901
/*
Edouard@491
   902
** 2015-03-02
Edouard@491
   903
**
Edouard@491
   904
** The author disclaims copyright to this source code.  In place of
Edouard@491
   905
** a legal notice, here is a blessing:
Edouard@491
   906
**
Edouard@491
   907
**    May you do good and not evil.
Edouard@491
   908
**    May you find forgiveness for yourself and forgive others.
Edouard@491
   909
**    May you share freely, never taking more than you give.
Edouard@491
   910
**
Edouard@491
   911
******************************************************************************
Edouard@491
   912
**
Edouard@491
   913
** This file contains code that is specific to Wind River's VxWorks
Edouard@491
   914
*/
Edouard@491
   915
#if defined(__RTP__) || defined(_WRS_KERNEL)
Edouard@491
   916
/* This is VxWorks.  Set up things specially for that OS
Edouard@491
   917
*/
Edouard@491
   918
#include <vxWorks.h>
Edouard@491
   919
#include <pthread.h>  /* amalgamator: dontcache */
Edouard@491
   920
#define OS_VXWORKS 1
Edouard@491
   921
#define SQLITE_OS_OTHER 0
Edouard@491
   922
#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
Edouard@491
   923
#define SQLITE_OMIT_LOAD_EXTENSION 1
Edouard@491
   924
#define SQLITE_ENABLE_LOCKING_STYLE 0
Edouard@491
   925
#define HAVE_UTIME 1
Edouard@491
   926
#else
Edouard@491
   927
/* This is not VxWorks. */
Edouard@491
   928
#define OS_VXWORKS 0
Edouard@491
   929
#define HAVE_FCHOWN 1
Edouard@491
   930
#define HAVE_READLINK 1
Edouard@491
   931
#define HAVE_LSTAT 1
Edouard@491
   932
#endif /* defined(_WRS_KERNEL) */
Edouard@491
   933
Edouard@491
   934
/************** End of vxworks.h *********************************************/
Edouard@491
   935
/************** Continuing where we left off in sqliteInt.h ******************/
Edouard@491
   936
Edouard@491
   937
/*
vb@130
   938
** These #defines should enable >2GB file support on POSIX if the
vb@130
   939
** underlying operating system supports it.  If the OS lacks
vb@130
   940
** large file support, or if the OS is windows, these should be no-ops.
vb@130
   941
**
vb@130
   942
** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any
vb@130
   943
** system #includes.  Hence, this block of code must be the very first
vb@130
   944
** code in all source files.
vb@130
   945
**
vb@130
   946
** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
vb@130
   947
** on the compiler command line.  This is necessary if you are compiling
vb@130
   948
** on a recent machine (ex: Red Hat 7.2) but you want your code to work
vb@130
   949
** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2
vb@130
   950
** without this option, LFS is enable.  But LFS does not exist in the kernel
vb@130
   951
** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary
vb@130
   952
** portability you should omit LFS.
vb@130
   953
**
vb@130
   954
** The previous paragraph was written in 2005.  (This paragraph is written
vb@130
   955
** on 2008-11-28.) These days, all Linux kernels support large files, so
vb@130
   956
** you should probably leave LFS enabled.  But some embedded platforms might
vb@130
   957
** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.
vb@130
   958
**
vb@130
   959
** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.
vb@130
   960
*/
vb@130
   961
#ifndef SQLITE_DISABLE_LFS
vb@130
   962
# define _LARGE_FILE       1
vb@130
   963
# ifndef _FILE_OFFSET_BITS
vb@130
   964
#   define _FILE_OFFSET_BITS 64
vb@130
   965
# endif
vb@130
   966
# define _LARGEFILE_SOURCE 1
vb@130
   967
#endif
vb@130
   968
edouard@1912
   969
/* The GCC_VERSION and MSVC_VERSION macros are used to
edouard@1912
   970
** conditionally include optimizations for each of these compilers.  A
edouard@1912
   971
** value of 0 means that compiler is not being used.  The
edouard@1912
   972
** SQLITE_DISABLE_INTRINSIC macro means do not use any compiler-specific
edouard@1912
   973
** optimizations, and hence set all compiler macros to 0
edouard@1912
   974
**
edouard@1912
   975
** There was once also a CLANG_VERSION macro.  However, we learn that the
edouard@1912
   976
** version numbers in clang are for "marketing" only and are inconsistent
edouard@1912
   977
** and unreliable.  Fortunately, all versions of clang also recognize the
edouard@1912
   978
** gcc version numbers and have reasonable settings for gcc version numbers,
edouard@1912
   979
** so the GCC_VERSION macro will be set to a correct non-zero value even
edouard@1912
   980
** when compiling with clang.
edouard@1912
   981
*/
edouard@1912
   982
#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)
Edouard@491
   983
# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)
Edouard@491
   984
#else
Edouard@491
   985
# define GCC_VERSION 0
Edouard@491
   986
#endif
edouard@1912
   987
#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)
edouard@1912
   988
# define MSVC_VERSION _MSC_VER
edouard@1912
   989
#else
edouard@1912
   990
# define MSVC_VERSION 0
edouard@1912
   991
#endif
Edouard@491
   992
Edouard@491
   993
/* Needed for various definitions... */
Edouard@491
   994
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
Edouard@491
   995
# define _GNU_SOURCE
Edouard@491
   996
#endif
Edouard@491
   997
Edouard@491
   998
#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)
Edouard@491
   999
# define _BSD_SOURCE
Edouard@491
  1000
#endif
Edouard@491
  1001
vb@130
  1002
/*
vb@130
  1003
** For MinGW, check to see if we can include the header file containing its
vb@130
  1004
** version information, among other things.  Normally, this internal MinGW
vb@130
  1005
** header file would [only] be included automatically by other MinGW header
vb@130
  1006
** files; however, the contained version information is now required by this
vb@130
  1007
** header file to work around binary compatibility issues (see below) and
vb@130
  1008
** this is the only known way to reliably obtain it.  This entire #if block
vb@130
  1009
** would be completely unnecessary if there was any other way of detecting
vb@130
  1010
** MinGW via their preprocessor (e.g. if they customized their GCC to define
vb@130
  1011
** some MinGW-specific macros).  When compiling for MinGW, either the
vb@130
  1012
** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be
vb@130
  1013
** defined; otherwise, detection of conditions specific to MinGW will be
vb@130
  1014
** disabled.
vb@130
  1015
*/
vb@130
  1016
#if defined(_HAVE_MINGW_H)
vb@130
  1017
# include "mingw.h"
vb@130
  1018
#elif defined(_HAVE__MINGW_H)
vb@130
  1019
# include "_mingw.h"
vb@130
  1020
#endif
vb@130
  1021
vb@130
  1022
/*
vb@130
  1023
** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T
vb@130
  1024
** define is required to maintain binary compatibility with the MSVC runtime
vb@130
  1025
** library in use (e.g. for Windows XP).
vb@130
  1026
*/
vb@130
  1027
#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \
vb@130
  1028
    defined(_WIN32) && !defined(_WIN64) && \
vb@130
  1029
    defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
vb@130
  1030
    defined(__MSVCRT__)
vb@130
  1031
# define _USE_32BIT_TIME_T
vb@130
  1032
#endif
vb@130
  1033
vb@130
  1034
/* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear
vb@130
  1035
** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for
vb@130
  1036
** MinGW.
vb@130
  1037
*/
vb@130
  1038
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
vb@130
  1039
/************** Begin file sqlite3.h *****************************************/
vb@130
  1040
/*
dz@3192
  1041
** 2001-09-15
vb@130
  1042
**
vb@130
  1043
** The author disclaims copyright to this source code.  In place of
vb@130
  1044
** a legal notice, here is a blessing:
vb@130
  1045
**
vb@130
  1046
**    May you do good and not evil.
vb@130
  1047
**    May you find forgiveness for yourself and forgive others.
vb@130
  1048
**    May you share freely, never taking more than you give.
vb@130
  1049
**
vb@130
  1050
*************************************************************************
vb@130
  1051
** This header file defines the interface that the SQLite library
vb@130
  1052
** presents to client programs.  If a C-function, structure, datatype,
vb@130
  1053
** or constant definition does not appear in this file, then it is
vb@130
  1054
** not a published API of SQLite, is subject to change without
vb@130
  1055
** notice, and should not be referenced by programs that use SQLite.
vb@130
  1056
**
vb@130
  1057
** Some of the definitions that are in this file are marked as
vb@130
  1058
** "experimental".  Experimental interfaces are normally new
vb@130
  1059
** features recently added to SQLite.  We do not anticipate changes
vb@130
  1060
** to experimental interfaces but reserve the right to make minor changes
vb@130
  1061
** if experience from use "in the wild" suggest such changes are prudent.
vb@130
  1062
**
vb@130
  1063
** The official C-language API documentation for SQLite is derived
vb@130
  1064
** from comments in this file.  This file is the authoritative source
Edouard@491
  1065
** on how SQLite interfaces are supposed to operate.
vb@130
  1066
**
vb@130
  1067
** The name of this file under configuration management is "sqlite.h.in".
vb@130
  1068
** The makefile makes some minor changes to this file (such as inserting
vb@130
  1069
** the version number) and changes its name to "sqlite3.h" as
vb@130
  1070
** part of the build process.
vb@130
  1071
*/
edouard@1912
  1072
#ifndef SQLITE3_H
edouard@1912
  1073
#define SQLITE3_H
vb@130
  1074
#include <stdarg.h>     /* Needed for the definition of va_list */
vb@130
  1075
vb@130
  1076
/*
vb@130
  1077
** Make sure we can call this stuff from C++.
vb@130
  1078
*/
vb@130
  1079
#if 0
vb@130
  1080
extern "C" {
vb@130
  1081
#endif
vb@130
  1082
vb@130
  1083
vb@130
  1084
/*
Edouard@491
  1085
** Provide the ability to override linkage features of the interface.
vb@130
  1086
*/
vb@130
  1087
#ifndef SQLITE_EXTERN
vb@130
  1088
# define SQLITE_EXTERN extern
vb@130
  1089
#endif
vb@130
  1090
#ifndef SQLITE_API
vb@130
  1091
# define SQLITE_API
vb@130
  1092
#endif
Edouard@491
  1093
#ifndef SQLITE_CDECL
Edouard@491
  1094
# define SQLITE_CDECL
Edouard@491
  1095
#endif
edouard@1912
  1096
#ifndef SQLITE_APICALL
edouard@1912
  1097
# define SQLITE_APICALL
edouard@1912
  1098
#endif
Edouard@491
  1099
#ifndef SQLITE_STDCALL
edouard@1912
  1100
# define SQLITE_STDCALL SQLITE_APICALL
edouard@1912
  1101
#endif
edouard@1912
  1102
#ifndef SQLITE_CALLBACK
edouard@1912
  1103
# define SQLITE_CALLBACK
edouard@1912
  1104
#endif
edouard@1912
  1105
#ifndef SQLITE_SYSAPI
edouard@1912
  1106
# define SQLITE_SYSAPI
Edouard@491
  1107
#endif
vb@130
  1108
vb@130
  1109
/*
vb@130
  1110
** These no-op macros are used in front of interfaces to mark those
vb@130
  1111
** interfaces as either deprecated or experimental.  New applications
Edouard@491
  1112
** should not use deprecated interfaces - they are supported for backwards
vb@130
  1113
** compatibility only.  Application writers should be aware that
vb@130
  1114
** experimental interfaces are subject to change in point releases.
vb@130
  1115
**
vb@130
  1116
** These macros used to resolve to various kinds of compiler magic that
vb@130
  1117
** would generate warning messages when they were used.  But that
vb@130
  1118
** compiler magic ended up generating such a flurry of bug reports
vb@130
  1119
** that we have taken it all out and gone back to using simple
vb@130
  1120
** noop macros.
vb@130
  1121
*/
vb@130
  1122
#define SQLITE_DEPRECATED
vb@130
  1123
#define SQLITE_EXPERIMENTAL
vb@130
  1124
vb@130
  1125
/*
vb@130
  1126
** Ensure these symbols were not defined by some previous header file.
vb@130
  1127
*/
vb@130
  1128
#ifdef SQLITE_VERSION
vb@130
  1129
# undef SQLITE_VERSION
vb@130
  1130
#endif
vb@130
  1131
#ifdef SQLITE_VERSION_NUMBER
vb@130
  1132
# undef SQLITE_VERSION_NUMBER
vb@130
  1133
#endif
vb@130
  1134
vb@130
  1135
/*
vb@130
  1136
** CAPI3REF: Compile-Time Library Version Numbers
vb@130
  1137
**
vb@130
  1138
** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
vb@130
  1139
** evaluates to a string literal that is the SQLite version in the
vb@130
  1140
** format "X.Y.Z" where X is the major version number (always 3 for
vb@130
  1141
** SQLite3) and Y is the minor version number and Z is the release number.)^
vb@130
  1142
** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
vb@130
  1143
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
vb@130
  1144
** numbers used in [SQLITE_VERSION].)^
vb@130
  1145
** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
vb@130
  1146
** be larger than the release from which it is derived.  Either Y will
vb@130
  1147
** be held constant and Z will be incremented or else Y will be incremented
vb@130
  1148
** and Z will be reset to zero.
vb@130
  1149
**
edouard@1912
  1150
** Since [version 3.6.18] ([dateof:3.6.18]), 
edouard@1912
  1151
** SQLite source code has been stored in the
vb@130
  1152
** <a href="http://www.fossil-scm.org/">Fossil configuration management
vb@130
  1153
** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to
vb@130
  1154
** a string which identifies a particular check-in of SQLite
vb@130
  1155
** within its configuration management system.  ^The SQLITE_SOURCE_ID
edouard@1912
  1156
** string contains the date and time of the check-in (UTC) and a SHA1
dz@3192
  1157
** or SHA3-256 hash of the entire source tree.  If the source code has
dz@3192
  1158
** been edited in any way since it was last checked in, then the last
dz@3192
  1159
** four hexadecimal digits of the hash may be modified.
vb@130
  1160
**
vb@130
  1161
** See also: [sqlite3_libversion()],
vb@130
  1162
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
vb@130
  1163
** [sqlite_version()] and [sqlite_source_id()].
vb@130
  1164
*/
dz@3192
  1165
#define SQLITE_VERSION        "3.26.0"
dz@3192
  1166
#define SQLITE_VERSION_NUMBER 3026000
dz@3192
  1167
#define SQLITE_SOURCE_ID      "2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238b4f9"
vb@130
  1168
vb@130
  1169
/*
vb@130
  1170
** CAPI3REF: Run-Time Library Version Numbers
edouard@1912
  1171
** KEYWORDS: sqlite3_version sqlite3_sourceid
vb@130
  1172
**
vb@130
  1173
** These interfaces provide the same information as the [SQLITE_VERSION],
vb@130
  1174
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
vb@130
  1175
** but are associated with the library instead of the header file.  ^(Cautious
vb@130
  1176
** programmers might include assert() statements in their application to
vb@130
  1177
** verify that values returned by these interfaces match the macros in
Edouard@491
  1178
** the header, and thus ensure that the application is
vb@130
  1179
** compiled with matching library and header files.
vb@130
  1180
**
vb@130
  1181
** <blockquote><pre>
vb@130
  1182
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
dz@3192
  1183
** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
vb@130
  1184
** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
vb@130
  1185
** </pre></blockquote>)^
vb@130
  1186
**
vb@130
  1187
** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
vb@130
  1188
** macro.  ^The sqlite3_libversion() function returns a pointer to the
vb@130
  1189
** to the sqlite3_version[] string constant.  The sqlite3_libversion()
vb@130
  1190
** function is provided for use in DLLs since DLL users usually do not have
vb@130
  1191
** direct access to string constants within the DLL.  ^The
vb@130
  1192
** sqlite3_libversion_number() function returns an integer equal to
dz@3192
  1193
** [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns 
vb@130
  1194
** a pointer to a string constant whose value is the same as the 
dz@3192
  1195
** [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built
dz@3192
  1196
** using an edited copy of [the amalgamation], then the last four characters
dz@3192
  1197
** of the hash might be different from [SQLITE_SOURCE_ID].)^
vb@130
  1198
**
vb@130
  1199
** See also: [sqlite_version()] and [sqlite_source_id()].
vb@130
  1200
*/
vb@130
  1201
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
edouard@1912
  1202
SQLITE_API const char *sqlite3_libversion(void);
edouard@1912
  1203
SQLITE_API const char *sqlite3_sourceid(void);
edouard@1912
  1204
SQLITE_API int sqlite3_libversion_number(void);
vb@130
  1205
vb@130
  1206
/*
vb@130
  1207
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
vb@130
  1208
**
vb@130
  1209
** ^The sqlite3_compileoption_used() function returns 0 or 1 
vb@130
  1210
** indicating whether the specified option was defined at 
vb@130
  1211
** compile time.  ^The SQLITE_ prefix may be omitted from the 
vb@130
  1212
** option name passed to sqlite3_compileoption_used().  
vb@130
  1213
**
vb@130
  1214
** ^The sqlite3_compileoption_get() function allows iterating
vb@130
  1215
** over the list of options that were defined at compile time by
vb@130
  1216
** returning the N-th compile time option string.  ^If N is out of range,
vb@130
  1217
** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ 
vb@130
  1218
** prefix is omitted from any strings returned by 
vb@130
  1219
** sqlite3_compileoption_get().
vb@130
  1220
**
vb@130
  1221
** ^Support for the diagnostic functions sqlite3_compileoption_used()
vb@130
  1222
** and sqlite3_compileoption_get() may be omitted by specifying the 
vb@130
  1223
** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
vb@130
  1224
**
vb@130
  1225
** See also: SQL functions [sqlite_compileoption_used()] and
vb@130
  1226
** [sqlite_compileoption_get()] and the [compile_options pragma].
vb@130
  1227
*/
vb@130
  1228
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
edouard@1912
  1229
SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
edouard@1912
  1230
SQLITE_API const char *sqlite3_compileoption_get(int N);
vb@130
  1231
#endif
vb@130
  1232
vb@130
  1233
/*
vb@130
  1234
** CAPI3REF: Test To See If The Library Is Threadsafe
vb@130
  1235
**
vb@130
  1236
** ^The sqlite3_threadsafe() function returns zero if and only if
vb@130
  1237
** SQLite was compiled with mutexing code omitted due to the
vb@130
  1238
** [SQLITE_THREADSAFE] compile-time option being set to 0.
vb@130
  1239
**
vb@130
  1240
** SQLite can be compiled with or without mutexes.  When
vb@130
  1241
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
vb@130
  1242
** are enabled and SQLite is threadsafe.  When the
vb@130
  1243
** [SQLITE_THREADSAFE] macro is 0, 
vb@130
  1244
** the mutexes are omitted.  Without the mutexes, it is not safe
vb@130
  1245
** to use SQLite concurrently from more than one thread.
vb@130
  1246
**
vb@130
  1247
** Enabling mutexes incurs a measurable performance penalty.
vb@130
  1248
** So if speed is of utmost importance, it makes sense to disable
vb@130
  1249
** the mutexes.  But for maximum safety, mutexes should be enabled.
vb@130
  1250
** ^The default behavior is for mutexes to be enabled.
vb@130
  1251
**
vb@130
  1252
** This interface can be used by an application to make sure that the
vb@130
  1253
** version of SQLite that it is linking against was compiled with
vb@130
  1254
** the desired setting of the [SQLITE_THREADSAFE] macro.
vb@130
  1255
**
vb@130
  1256
** This interface only reports on the compile-time mutex setting
vb@130
  1257
** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with
vb@130
  1258
** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
vb@130
  1259
** can be fully or partially disabled using a call to [sqlite3_config()]
vb@130
  1260
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
Edouard@491
  1261
** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the
vb@130
  1262
** sqlite3_threadsafe() function shows only the compile-time setting of
vb@130
  1263
** thread safety, not any run-time changes to that setting made by
vb@130
  1264
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
vb@130
  1265
** is unchanged by calls to sqlite3_config().)^
vb@130
  1266
**
vb@130
  1267
** See the [threading mode] documentation for additional information.
vb@130
  1268
*/
edouard@1912
  1269
SQLITE_API int sqlite3_threadsafe(void);
vb@130
  1270
vb@130
  1271
/*
vb@130
  1272
** CAPI3REF: Database Connection Handle
vb@130
  1273
** KEYWORDS: {database connection} {database connections}
vb@130
  1274
**
vb@130
  1275
** Each open SQLite database is represented by a pointer to an instance of
vb@130
  1276
** the opaque structure named "sqlite3".  It is useful to think of an sqlite3
vb@130
  1277
** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and
vb@130
  1278
** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
vb@130
  1279
** and [sqlite3_close_v2()] are its destructors.  There are many other
vb@130
  1280
** interfaces (such as
vb@130
  1281
** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
vb@130
  1282
** [sqlite3_busy_timeout()] to name but three) that are methods on an
vb@130
  1283
** sqlite3 object.
vb@130
  1284
*/
vb@130
  1285
typedef struct sqlite3 sqlite3;
vb@130
  1286
vb@130
  1287
/*
vb@130
  1288
** CAPI3REF: 64-Bit Integer Types
vb@130
  1289
** KEYWORDS: sqlite_int64 sqlite_uint64
vb@130
  1290
**
vb@130
  1291
** Because there is no cross-platform way to specify 64-bit integer types
vb@130
  1292
** SQLite includes typedefs for 64-bit signed and unsigned integers.
vb@130
  1293
**
vb@130
  1294
** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
vb@130
  1295
** The sqlite_int64 and sqlite_uint64 types are supported for backwards
vb@130
  1296
** compatibility only.
vb@130
  1297
**
vb@130
  1298
** ^The sqlite3_int64 and sqlite_int64 types can store integer values
vb@130
  1299
** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The
vb@130
  1300
** sqlite3_uint64 and sqlite_uint64 types can store integer values 
vb@130
  1301
** between 0 and +18446744073709551615 inclusive.
vb@130
  1302
*/
vb@130
  1303
#ifdef SQLITE_INT64_TYPE
vb@130
  1304
  typedef SQLITE_INT64_TYPE sqlite_int64;
edouard@1912
  1305
# ifdef SQLITE_UINT64_TYPE
edouard@1912
  1306
    typedef SQLITE_UINT64_TYPE sqlite_uint64;
edouard@1912
  1307
# else  
edouard@1912
  1308
    typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
edouard@1912
  1309
# endif
vb@130
  1310
#elif defined(_MSC_VER) || defined(__BORLANDC__)
vb@130
  1311
  typedef __int64 sqlite_int64;
vb@130
  1312
  typedef unsigned __int64 sqlite_uint64;
vb@130
  1313
#else
vb@130
  1314
  typedef long long int sqlite_int64;
vb@130
  1315
  typedef unsigned long long int sqlite_uint64;
vb@130
  1316
#endif
vb@130
  1317
typedef sqlite_int64 sqlite3_int64;
vb@130
  1318
typedef sqlite_uint64 sqlite3_uint64;
vb@130
  1319
vb@130
  1320
/*
vb@130
  1321
** If compiling for a processor that lacks floating point support,
vb@130
  1322
** substitute integer for floating-point.
vb@130
  1323
*/
vb@130
  1324
#ifdef SQLITE_OMIT_FLOATING_POINT
vb@130
  1325
# define double sqlite3_int64
vb@130
  1326
#endif
vb@130
  1327
vb@130
  1328
/*
vb@130
  1329
** CAPI3REF: Closing A Database Connection
Edouard@491
  1330
** DESTRUCTOR: sqlite3
vb@130
  1331
**
vb@130
  1332
** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
vb@130
  1333
** for the [sqlite3] object.
vb@130
  1334
** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
vb@130
  1335
** the [sqlite3] object is successfully destroyed and all associated
vb@130
  1336
** resources are deallocated.
vb@130
  1337
**
vb@130
  1338
** ^If the database connection is associated with unfinalized prepared
vb@130
  1339
** statements or unfinished sqlite3_backup objects then sqlite3_close()
vb@130
  1340
** will leave the database connection open and return [SQLITE_BUSY].
vb@130
  1341
** ^If sqlite3_close_v2() is called with unfinalized prepared statements
vb@130
  1342
** and/or unfinished sqlite3_backups, then the database connection becomes
vb@130
  1343
** an unusable "zombie" which will automatically be deallocated when the
vb@130
  1344
** last prepared statement is finalized or the last sqlite3_backup is
vb@130
  1345
** finished.  The sqlite3_close_v2() interface is intended for use with
vb@130
  1346
** host languages that are garbage collected, and where the order in which
vb@130
  1347
** destructors are called is arbitrary.
vb@130
  1348
**
vb@130
  1349
** Applications should [sqlite3_finalize | finalize] all [prepared statements],
vb@130
  1350
** [sqlite3_blob_close | close] all [BLOB handles], and 
vb@130
  1351
** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
vb@130
  1352
** with the [sqlite3] object prior to attempting to close the object.  ^If
vb@130
  1353
** sqlite3_close_v2() is called on a [database connection] that still has
vb@130
  1354
** outstanding [prepared statements], [BLOB handles], and/or
vb@130
  1355
** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation
vb@130
  1356
** of resources is deferred until all [prepared statements], [BLOB handles],
vb@130
  1357
** and [sqlite3_backup] objects are also destroyed.
vb@130
  1358
**
vb@130
  1359
** ^If an [sqlite3] object is destroyed while a transaction is open,
vb@130
  1360
** the transaction is automatically rolled back.
vb@130
  1361
**
vb@130
  1362
** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]
vb@130
  1363
** must be either a NULL
vb@130
  1364
** pointer or an [sqlite3] object pointer obtained
vb@130
  1365
** from [sqlite3_open()], [sqlite3_open16()], or
vb@130
  1366
** [sqlite3_open_v2()], and not previously closed.
vb@130
  1367
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
vb@130
  1368
** argument is a harmless no-op.
vb@130
  1369
*/
edouard@1912
  1370
SQLITE_API int sqlite3_close(sqlite3*);
edouard@1912
  1371
SQLITE_API int sqlite3_close_v2(sqlite3*);
vb@130
  1372
vb@130
  1373
/*
vb@130
  1374
** The type for a callback function.
vb@130
  1375
** This is legacy and deprecated.  It is included for historical
vb@130
  1376
** compatibility and is not documented.
vb@130
  1377
*/
vb@130
  1378
typedef int (*sqlite3_callback)(void*,int,char**, char**);
vb@130
  1379
vb@130
  1380
/*
vb@130
  1381
** CAPI3REF: One-Step Query Execution Interface
Edouard@491
  1382
** METHOD: sqlite3
vb@130
  1383
**
vb@130
  1384
** The sqlite3_exec() interface is a convenience wrapper around
vb@130
  1385
** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
vb@130
  1386
** that allows an application to run multiple statements of SQL
vb@130
  1387
** without having to use a lot of C code. 
vb@130
  1388
**
vb@130
  1389
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
vb@130
  1390
** semicolon-separate SQL statements passed into its 2nd argument,
vb@130
  1391
** in the context of the [database connection] passed in as its 1st
vb@130
  1392
** argument.  ^If the callback function of the 3rd argument to
vb@130
  1393
** sqlite3_exec() is not NULL, then it is invoked for each result row
vb@130
  1394
** coming out of the evaluated SQL statements.  ^The 4th argument to
vb@130
  1395
** sqlite3_exec() is relayed through to the 1st argument of each
vb@130
  1396
** callback invocation.  ^If the callback pointer to sqlite3_exec()
vb@130
  1397
** is NULL, then no callback is ever invoked and result rows are
vb@130
  1398
** ignored.
vb@130
  1399
**
vb@130
  1400
** ^If an error occurs while evaluating the SQL statements passed into
vb@130
  1401
** sqlite3_exec(), then execution of the current statement stops and
vb@130
  1402
** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()
vb@130
  1403
** is not NULL then any error message is written into memory obtained
vb@130
  1404
** from [sqlite3_malloc()] and passed back through the 5th parameter.
vb@130
  1405
** To avoid memory leaks, the application should invoke [sqlite3_free()]
vb@130
  1406
** on error message strings returned through the 5th parameter of
Edouard@491
  1407
** sqlite3_exec() after the error message string is no longer needed.
vb@130
  1408
** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
vb@130
  1409
** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
vb@130
  1410
** NULL before returning.
vb@130
  1411
**
vb@130
  1412
** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
vb@130
  1413
** routine returns SQLITE_ABORT without invoking the callback again and
vb@130
  1414
** without running any subsequent SQL statements.
vb@130
  1415
**
vb@130
  1416
** ^The 2nd argument to the sqlite3_exec() callback function is the
vb@130
  1417
** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()
vb@130
  1418
** callback is an array of pointers to strings obtained as if from
vb@130
  1419
** [sqlite3_column_text()], one for each column.  ^If an element of a
vb@130
  1420
** result row is NULL then the corresponding string pointer for the
vb@130
  1421
** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the
vb@130
  1422
** sqlite3_exec() callback is an array of pointers to strings where each
vb@130
  1423
** entry represents the name of corresponding result column as obtained
vb@130
  1424
** from [sqlite3_column_name()].
vb@130
  1425
**
vb@130
  1426
** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
vb@130
  1427
** to an empty string, or a pointer that contains only whitespace and/or 
vb@130
  1428
** SQL comments, then no SQL statements are evaluated and the database
vb@130
  1429
** is not changed.
vb@130
  1430
**
vb@130
  1431
** Restrictions:
vb@130
  1432
**
vb@130
  1433
** <ul>
Edouard@491
  1434
** <li> The application must ensure that the 1st parameter to sqlite3_exec()
vb@130
  1435
**      is a valid and open [database connection].
vb@130
  1436
** <li> The application must not close the [database connection] specified by
vb@130
  1437
**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
vb@130
  1438
** <li> The application must not modify the SQL statement text passed into
vb@130
  1439
**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
vb@130
  1440
** </ul>
vb@130
  1441
*/
edouard@1912
  1442
SQLITE_API int sqlite3_exec(
vb@130
  1443
  sqlite3*,                                  /* An open database */
vb@130
  1444
  const char *sql,                           /* SQL to be evaluated */
vb@130
  1445
  int (*callback)(void*,int,char**,char**),  /* Callback function */
vb@130
  1446
  void *,                                    /* 1st argument to callback */
vb@130
  1447
  char **errmsg                              /* Error msg written here */
vb@130
  1448
);
vb@130
  1449
vb@130
  1450
/*
vb@130
  1451
** CAPI3REF: Result Codes
vb@130
  1452
** KEYWORDS: {result code definitions}
vb@130
  1453
**
vb@130
  1454
** Many SQLite functions return an integer result code from the set shown
vb@130
  1455
** here in order to indicate success or failure.
vb@130
  1456
**
vb@130
  1457
** New error codes may be added in future versions of SQLite.
vb@130
  1458
**
vb@130
  1459
** See also: [extended result code definitions]
vb@130
  1460
*/
vb@130
  1461
#define SQLITE_OK           0   /* Successful result */
vb@130
  1462
/* beginning-of-error-codes */
dz@3192
  1463
#define SQLITE_ERROR        1   /* Generic error */
vb@130
  1464
#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
vb@130
  1465
#define SQLITE_PERM         3   /* Access permission denied */
vb@130
  1466
#define SQLITE_ABORT        4   /* Callback routine requested an abort */
vb@130
  1467
#define SQLITE_BUSY         5   /* The database file is locked */
vb@130
  1468
#define SQLITE_LOCKED       6   /* A table in the database is locked */
vb@130
  1469
#define SQLITE_NOMEM        7   /* A malloc() failed */
vb@130
  1470
#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
vb@130
  1471
#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
vb@130
  1472
#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
vb@130
  1473
#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
vb@130
  1474
#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */
vb@130
  1475
#define SQLITE_FULL        13   /* Insertion failed because database is full */
vb@130
  1476
#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
vb@130
  1477
#define SQLITE_PROTOCOL    15   /* Database lock protocol error */
dz@3192
  1478
#define SQLITE_EMPTY       16   /* Internal use only */
vb@130
  1479
#define SQLITE_SCHEMA      17   /* The database schema changed */
vb@130
  1480
#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
vb@130
  1481
#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
vb@130
  1482
#define SQLITE_MISMATCH    20   /* Data type mismatch */
vb@130
  1483
#define SQLITE_MISUSE      21   /* Library used incorrectly */
vb@130
  1484
#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
vb@130
  1485
#define SQLITE_AUTH        23   /* Authorization denied */
dz@3192
  1486
#define SQLITE_FORMAT      24   /* Not used */
vb@130
  1487
#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
vb@130
  1488
#define SQLITE_NOTADB      26   /* File opened that is not a database file */
vb@130
  1489
#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */
vb@130
  1490
#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */
vb@130
  1491
#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
vb@130
  1492
#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
vb@130
  1493
/* end-of-error-codes */
vb@130
  1494
vb@130
  1495
/*
vb@130
  1496
** CAPI3REF: Extended Result Codes
vb@130
  1497
** KEYWORDS: {extended result code definitions}
vb@130
  1498
**
vb@130
  1499
** In its default configuration, SQLite API routines return one of 30 integer
vb@130
  1500
** [result codes].  However, experience has shown that many of
vb@130
  1501
** these result codes are too coarse-grained.  They do not provide as
vb@130
  1502
** much information about problems as programmers might like.  In an effort to
edouard@1912
  1503
** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]
edouard@1912
  1504
** and later) include
vb@130
  1505
** support for additional result codes that provide more detailed information
vb@130
  1506
** about errors. These [extended result codes] are enabled or disabled
vb@130
  1507
** on a per database connection basis using the
vb@130
  1508
** [sqlite3_extended_result_codes()] API.  Or, the extended code for
vb@130
  1509
** the most recent error can be obtained using
vb@130
  1510
** [sqlite3_extended_errcode()].
vb@130
  1511
*/
dz@3192
  1512
#define SQLITE_ERROR_MISSING_COLLSEQ   (SQLITE_ERROR | (1<<8))
dz@3192
  1513
#define SQLITE_ERROR_RETRY             (SQLITE_ERROR | (2<<8))
dz@3192
  1514
#define SQLITE_ERROR_SNAPSHOT          (SQLITE_ERROR | (3<<8))
vb@130
  1515
#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
vb@130
  1516
#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))
vb@130
  1517
#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))
vb@130
  1518
#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))
vb@130
  1519
#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))
vb@130
  1520
#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))
vb@130
  1521
#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))
vb@130
  1522
#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))
vb@130
  1523
#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))
vb@130
  1524
#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))
vb@130
  1525
#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))
vb@130
  1526
#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))
vb@130
  1527
#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))
vb@130
  1528
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
vb@130
  1529
#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))
vb@130
  1530
#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))
vb@130
  1531
#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))
vb@130
  1532
#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))
vb@130
  1533
#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))
vb@130
  1534
#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))
vb@130
  1535
#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))
vb@130
  1536
#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))
vb@130
  1537
#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))
vb@130
  1538
#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))
vb@130
  1539
#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))
vb@130
  1540
#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))
Edouard@491
  1541
#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))
Edouard@491
  1542
#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))
dz@3192
  1543
#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))
dz@3192
  1544
#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))
dz@3192
  1545
#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))
vb@130
  1546
#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
dz@3192
  1547
#define SQLITE_LOCKED_VTAB             (SQLITE_LOCKED |  (2<<8))
vb@130
  1548
#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
vb@130
  1549
#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
vb@130
  1550
#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
vb@130
  1551
#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
vb@130
  1552
#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
vb@130
  1553
#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
dz@3192
  1554
#define SQLITE_CANTOPEN_DIRTYWAL       (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
vb@130
  1555
#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
dz@3192
  1556
#define SQLITE_CORRUPT_SEQUENCE        (SQLITE_CORRUPT | (2<<8))
vb@130
  1557
#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
vb@130
  1558
#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
vb@130
  1559
#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
vb@130
  1560
#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
dz@3192
  1561
#define SQLITE_READONLY_CANTINIT       (SQLITE_READONLY | (5<<8))
dz@3192
  1562
#define SQLITE_READONLY_DIRECTORY      (SQLITE_READONLY | (6<<8))
vb@130
  1563
#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
vb@130
  1564
#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))
vb@130
  1565
#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))
vb@130
  1566
#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))
vb@130
  1567
#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))
vb@130
  1568
#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))
vb@130
  1569
#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))
vb@130
  1570
#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))
vb@130
  1571
#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))
vb@130
  1572
#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))
vb@130
  1573
#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))
vb@130
  1574
#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))
vb@130
  1575
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
vb@130
  1576
#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))
Edouard@491
  1577
#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))
edouard@1912
  1578
#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))
vb@130
  1579
vb@130
  1580
/*
vb@130
  1581
** CAPI3REF: Flags For File Open Operations
vb@130
  1582
**
vb@130
  1583
** These bit values are intended for use in the
vb@130
  1584
** 3rd parameter to the [sqlite3_open_v2()] interface and
vb@130
  1585
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
vb@130
  1586
*/
vb@130
  1587
#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */
vb@130
  1588
#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */
vb@130
  1589
#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */
vb@130
  1590
#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */
vb@130
  1591
#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */
vb@130
  1592
#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */
vb@130
  1593
#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */
vb@130
  1594
#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */
vb@130
  1595
#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */
vb@130
  1596
#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */
vb@130
  1597
#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */
vb@130
  1598
#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */
vb@130
  1599
#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */
vb@130
  1600
#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */
vb@130
  1601
#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */
vb@130
  1602
#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */
vb@130
  1603
#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */
vb@130
  1604
#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */
vb@130
  1605
#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */
vb@130
  1606
#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */
vb@130
  1607
vb@130
  1608
/* Reserved:                         0x00F00000 */
vb@130
  1609
vb@130
  1610
/*
vb@130
  1611
** CAPI3REF: Device Characteristics
vb@130
  1612
**
vb@130
  1613
** The xDeviceCharacteristics method of the [sqlite3_io_methods]
vb@130
  1614
** object returns an integer which is a vector of these
vb@130
  1615
** bit values expressing I/O characteristics of the mass storage
vb@130
  1616
** device that holds the file that the [sqlite3_io_methods]
vb@130
  1617
** refers to.
vb@130
  1618
**
vb@130
  1619
** The SQLITE_IOCAP_ATOMIC property means that all writes of
vb@130
  1620
** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
vb@130
  1621
** mean that writes of blocks that are nnn bytes in size and
vb@130
  1622
** are aligned to an address which is an integer multiple of
vb@130
  1623
** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
vb@130
  1624
** that when data is appended to a file, the data is appended
vb@130
  1625
** first then the size of the file is extended, never the other
vb@130
  1626
** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
vb@130
  1627
** information is written to disk in the same order as calls
vb@130
  1628
** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
vb@130
  1629
** after reboot following a crash or power loss, the only bytes in a
vb@130
  1630
** file that were written at the application level might have changed
vb@130
  1631
** and that adjacent bytes, even bytes within the same sector are
vb@130
  1632
** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
edouard@1912
  1633
** flag indicates that a file cannot be deleted when open.  The
vb@130
  1634
** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
vb@130
  1635
** read-only media and cannot be changed even by processes with
vb@130
  1636
** elevated privileges.
dz@3192
  1637
**
dz@3192
  1638
** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying
dz@3192
  1639
** filesystem supports doing multiple write operations atomically when those
dz@3192
  1640
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
dz@3192
  1641
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
vb@130
  1642
*/
vb@130
  1643
#define SQLITE_IOCAP_ATOMIC                 0x00000001
vb@130
  1644
#define SQLITE_IOCAP_ATOMIC512              0x00000002
vb@130
  1645
#define SQLITE_IOCAP_ATOMIC1K               0x00000004
vb@130
  1646
#define SQLITE_IOCAP_ATOMIC2K               0x00000008
vb@130
  1647
#define SQLITE_IOCAP_ATOMIC4K               0x00000010
vb@130
  1648
#define SQLITE_IOCAP_ATOMIC8K               0x00000020
vb@130
  1649
#define SQLITE_IOCAP_ATOMIC16K              0x00000040
vb@130
  1650
#define SQLITE_IOCAP_ATOMIC32K              0x00000080
vb@130
  1651
#define SQLITE_IOCAP_ATOMIC64K              0x00000100
vb@130
  1652
#define SQLITE_IOCAP_SAFE_APPEND            0x00000200
vb@130
  1653
#define SQLITE_IOCAP_SEQUENTIAL             0x00000400
vb@130
  1654
#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800
vb@130
  1655
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000
vb@130
  1656
#define SQLITE_IOCAP_IMMUTABLE              0x00002000
dz@3192
  1657
#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000
vb@130
  1658
vb@130
  1659
/*
vb@130
  1660
** CAPI3REF: File Locking Levels
vb@130
  1661
**
vb@130
  1662
** SQLite uses one of these integer values as the second
vb@130
  1663
** argument to calls it makes to the xLock() and xUnlock() methods
vb@130
  1664
** of an [sqlite3_io_methods] object.
vb@130
  1665
*/
vb@130
  1666
#define SQLITE_LOCK_NONE          0
vb@130
  1667
#define SQLITE_LOCK_SHARED        1
vb@130
  1668
#define SQLITE_LOCK_RESERVED      2
vb@130
  1669
#define SQLITE_LOCK_PENDING       3
vb@130
  1670
#define SQLITE_LOCK_EXCLUSIVE     4
vb@130
  1671
vb@130
  1672
/*
vb@130
  1673
** CAPI3REF: Synchronization Type Flags
vb@130
  1674
**
vb@130
  1675
** When SQLite invokes the xSync() method of an
vb@130
  1676
** [sqlite3_io_methods] object it uses a combination of
vb@130
  1677
** these integer values as the second argument.
vb@130
  1678
**
vb@130
  1679
** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
vb@130
  1680
** sync operation only needs to flush data to mass storage.  Inode
vb@130
  1681
** information need not be flushed. If the lower four bits of the flag
vb@130
  1682
** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
vb@130
  1683
** If the lower four bits equal SQLITE_SYNC_FULL, that means
vb@130
  1684
** to use Mac OS X style fullsync instead of fsync().
vb@130
  1685
**
vb@130
  1686
** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
vb@130
  1687
** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
vb@130
  1688
** settings.  The [synchronous pragma] determines when calls to the
vb@130
  1689
** xSync VFS method occur and applies uniformly across all platforms.
vb@130
  1690
** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how
vb@130
  1691
** energetic or rigorous or forceful the sync operations are and
vb@130
  1692
** only make a difference on Mac OSX for the default SQLite code.
vb@130
  1693
** (Third-party VFS implementations might also make the distinction
vb@130
  1694
** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the
vb@130
  1695
** operating systems natively supported by SQLite, only Mac OSX
vb@130
  1696
** cares about the difference.)
vb@130
  1697
*/
vb@130
  1698
#define SQLITE_SYNC_NORMAL        0x00002
vb@130
  1699
#define SQLITE_SYNC_FULL          0x00003
vb@130
  1700
#define SQLITE_SYNC_DATAONLY      0x00010
vb@130
  1701
vb@130
  1702
/*
vb@130
  1703
** CAPI3REF: OS Interface Open File Handle
vb@130
  1704
**
vb@130
  1705
** An [sqlite3_file] object represents an open file in the 
vb@130
  1706
** [sqlite3_vfs | OS interface layer].  Individual OS interface
vb@130
  1707
** implementations will
vb@130
  1708
** want to subclass this object by appending additional fields
vb@130
  1709
** for their own use.  The pMethods entry is a pointer to an
vb@130
  1710
** [sqlite3_io_methods] object that defines methods for performing
vb@130
  1711
** I/O operations on the open file.
vb@130
  1712
*/
vb@130
  1713
typedef struct sqlite3_file sqlite3_file;
vb@130
  1714
struct sqlite3_file {
vb@130
  1715
  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
vb@130
  1716
};
vb@130
  1717
vb@130
  1718
/*
vb@130
  1719
** CAPI3REF: OS Interface File Virtual Methods Object
vb@130
  1720
**
vb@130
  1721
** Every file opened by the [sqlite3_vfs.xOpen] method populates an
vb@130
  1722
** [sqlite3_file] object (or, more commonly, a subclass of the
vb@130
  1723
** [sqlite3_file] object) with a pointer to an instance of this object.
vb@130
  1724
** This object defines the methods used to perform various operations
vb@130
  1725
** against the open file represented by the [sqlite3_file] object.
vb@130
  1726
**
vb@130
  1727
** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element 
vb@130
  1728
** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
vb@130
  1729
** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The
vb@130
  1730
** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
vb@130
  1731
** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
vb@130
  1732
** to NULL.
vb@130
  1733
**
vb@130
  1734
** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
vb@130
  1735
** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().
vb@130
  1736
** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]
vb@130
  1737
** flag may be ORed in to indicate that only the data of the file
vb@130
  1738
** and not its inode needs to be synced.
vb@130
  1739
**
vb@130
  1740
** The integer values to xLock() and xUnlock() are one of
vb@130
  1741
** <ul>
vb@130
  1742
** <li> [SQLITE_LOCK_NONE],
vb@130
  1743
** <li> [SQLITE_LOCK_SHARED],
vb@130
  1744
** <li> [SQLITE_LOCK_RESERVED],
vb@130
  1745
** <li> [SQLITE_LOCK_PENDING], or
vb@130
  1746
** <li> [SQLITE_LOCK_EXCLUSIVE].
vb@130
  1747
** </ul>
vb@130
  1748
** xLock() increases the lock. xUnlock() decreases the lock.
vb@130
  1749
** The xCheckReservedLock() method checks whether any database connection,
vb@130
  1750
** either in this process or in some other process, is holding a RESERVED,
vb@130
  1751
** PENDING, or EXCLUSIVE lock on the file.  It returns true
vb@130
  1752
** if such a lock exists and false otherwise.
vb@130
  1753
**
vb@130
  1754
** The xFileControl() method is a generic interface that allows custom
vb@130
  1755
** VFS implementations to directly control an open file using the
vb@130
  1756
** [sqlite3_file_control()] interface.  The second "op" argument is an
vb@130
  1757
** integer opcode.  The third argument is a generic pointer intended to
vb@130
  1758
** point to a structure that may contain arguments or space in which to
vb@130
  1759
** write return values.  Potential uses for xFileControl() might be
vb@130
  1760
** functions to enable blocking locks with timeouts, to change the
vb@130
  1761
** locking strategy (for example to use dot-file locks), to inquire
vb@130
  1762
** about the status of a lock, or to break stale locks.  The SQLite
vb@130
  1763
** core reserves all opcodes less than 100 for its own use.
vb@130
  1764
** A [file control opcodes | list of opcodes] less than 100 is available.
vb@130
  1765
** Applications that define a custom xFileControl method should use opcodes
vb@130
  1766
** greater than 100 to avoid conflicts.  VFS implementations should
vb@130
  1767
** return [SQLITE_NOTFOUND] for file control opcodes that they do not
vb@130
  1768
** recognize.
vb@130
  1769
**
vb@130
  1770
** The xSectorSize() method returns the sector size of the
vb@130
  1771
** device that underlies the file.  The sector size is the
vb@130
  1772
** minimum write that can be performed without disturbing
vb@130
  1773
** other bytes in the file.  The xDeviceCharacteristics()
vb@130
  1774
** method returns a bit vector describing behaviors of the
vb@130
  1775
** underlying device:
vb@130
  1776
**
vb@130
  1777
** <ul>
vb@130
  1778
** <li> [SQLITE_IOCAP_ATOMIC]
vb@130
  1779
** <li> [SQLITE_IOCAP_ATOMIC512]
vb@130
  1780
** <li> [SQLITE_IOCAP_ATOMIC1K]
vb@130
  1781
** <li> [SQLITE_IOCAP_ATOMIC2K]
vb@130
  1782
** <li> [SQLITE_IOCAP_ATOMIC4K]
vb@130
  1783
** <li> [SQLITE_IOCAP_ATOMIC8K]
vb@130
  1784
** <li> [SQLITE_IOCAP_ATOMIC16K]
vb@130
  1785
** <li> [SQLITE_IOCAP_ATOMIC32K]
vb@130
  1786
** <li> [SQLITE_IOCAP_ATOMIC64K]
vb@130
  1787
** <li> [SQLITE_IOCAP_SAFE_APPEND]
vb@130
  1788
** <li> [SQLITE_IOCAP_SEQUENTIAL]
edouard@1912
  1789
** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]
edouard@1912
  1790
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
edouard@1912
  1791
** <li> [SQLITE_IOCAP_IMMUTABLE]
dz@3192
  1792
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
vb@130
  1793
** </ul>
vb@130
  1794
**
vb@130
  1795
** The SQLITE_IOCAP_ATOMIC property means that all writes of
vb@130
  1796
** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values
vb@130
  1797
** mean that writes of blocks that are nnn bytes in size and
vb@130
  1798
** are aligned to an address which is an integer multiple of
vb@130
  1799
** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
vb@130
  1800
** that when data is appended to a file, the data is appended
vb@130
  1801
** first then the size of the file is extended, never the other
vb@130
  1802
** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
vb@130
  1803
** information is written to disk in the same order as calls
vb@130
  1804
** to xWrite().
vb@130
  1805
**
vb@130
  1806
** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
vb@130
  1807
** in the unread portions of the buffer with zeros.  A VFS that
vb@130
  1808
** fails to zero-fill short reads might seem to work.  However,
vb@130
  1809
** failure to zero-fill short reads will eventually lead to
vb@130
  1810
** database corruption.
vb@130
  1811
*/
vb@130
  1812
typedef struct sqlite3_io_methods sqlite3_io_methods;
vb@130
  1813
struct sqlite3_io_methods {
vb@130
  1814
  int iVersion;
vb@130
  1815
  int (*xClose)(sqlite3_file*);
vb@130
  1816
  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
vb@130
  1817
  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
vb@130
  1818
  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
vb@130
  1819
  int (*xSync)(sqlite3_file*, int flags);
vb@130
  1820
  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
vb@130
  1821
  int (*xLock)(sqlite3_file*, int);
vb@130
  1822
  int (*xUnlock)(sqlite3_file*, int);
vb@130
  1823
  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
vb@130
  1824
  int (*xFileControl)(sqlite3_file*, int op, void *pArg);
vb@130
  1825
  int (*xSectorSize)(sqlite3_file*);
vb@130
  1826
  int (*xDeviceCharacteristics)(sqlite3_file*);
vb@130
  1827
  /* Methods above are valid for version 1 */
vb@130
  1828
  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
vb@130
  1829
  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
vb@130
  1830
  void (*xShmBarrier)(sqlite3_file*);
vb@130
  1831
  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
vb@130
  1832
  /* Methods above are valid for version 2 */
vb@130
  1833
  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
vb@130
  1834
  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
vb@130
  1835
  /* Methods above are valid for version 3 */
vb@130
  1836
  /* Additional methods may be added in future releases */
vb@130
  1837
};
vb@130
  1838
vb@130
  1839
/*
vb@130
  1840
** CAPI3REF: Standard File Control Opcodes
vb@130
  1841
** KEYWORDS: {file control opcodes} {file control opcode}
vb@130
  1842
**
vb@130
  1843
** These integer constants are opcodes for the xFileControl method
vb@130
  1844
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
vb@130
  1845
** interface.
vb@130
  1846
**
Edouard@491
  1847
** <ul>
Edouard@491
  1848
** <li>[[SQLITE_FCNTL_LOCKSTATE]]
vb@130
  1849
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This
vb@130
  1850
** opcode causes the xFileControl method to write the current state of
vb@130
  1851
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
vb@130
  1852
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
vb@130
  1853
** into an integer that the pArg argument points to. This capability
Edouard@491
  1854
** is used during testing and is only available when the SQLITE_TEST
Edouard@491
  1855
** compile-time option is used.
Edouard@491
  1856
**
vb@130
  1857
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
vb@130
  1858
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
vb@130
  1859
** layer a hint of how large the database file will grow to be during the
vb@130
  1860
** current transaction.  This hint is not guaranteed to be accurate but it
vb@130
  1861
** is often close.  The underlying VFS might choose to preallocate database
vb@130
  1862
** file space based on this hint in order to help writes to the database
vb@130
  1863
** file run faster.
vb@130
  1864
**
vb@130
  1865
** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
vb@130
  1866
** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
vb@130
  1867
** extends and truncates the database file in chunks of a size specified
vb@130
  1868
** by the user. The fourth argument to [sqlite3_file_control()] should 
vb@130
  1869
** point to an integer (type int) containing the new chunk-size to use
vb@130
  1870
** for the nominated database. Allocating database file space in large
vb@130
  1871
** chunks (say 1MB at a time), may reduce file-system fragmentation and
vb@130
  1872
** improve performance on some systems.
vb@130
  1873
**
vb@130
  1874
** <li>[[SQLITE_FCNTL_FILE_POINTER]]
vb@130
  1875
** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
vb@130
  1876
** to the [sqlite3_file] object associated with a particular database
Edouard@491
  1877
** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].
Edouard@491
  1878
**
Edouard@491
  1879
** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
Edouard@491
  1880
** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
Edouard@491
  1881
** to the [sqlite3_file] object associated with the journal file (either
Edouard@491
  1882
** the [rollback journal] or the [write-ahead log]) for a particular database
Edouard@491
  1883
** connection.  See also [SQLITE_FCNTL_FILE_POINTER].
vb@130
  1884
**
vb@130
  1885
** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
vb@130
  1886
** No longer in use.
vb@130
  1887
**
vb@130
  1888
** <li>[[SQLITE_FCNTL_SYNC]]
vb@130
  1889
** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
vb@130
  1890
** sent to the VFS immediately before the xSync method is invoked on a
vb@130
  1891
** database file descriptor. Or, if the xSync method is not invoked 
vb@130
  1892
** because the user has configured SQLite with 
vb@130
  1893
** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place 
vb@130
  1894
** of the xSync method. In most cases, the pointer argument passed with
vb@130
  1895
** this file-control is NULL. However, if the database file is being synced
vb@130
  1896
** as part of a multi-database commit, the argument points to a nul-terminated
vb@130
  1897
** string containing the transactions master-journal file name. VFSes that 
vb@130
  1898
** do not need this signal should silently ignore this opcode. Applications 
vb@130
  1899
** should not call [sqlite3_file_control()] with this opcode as doing so may 
vb@130
  1900
** disrupt the operation of the specialized VFSes that do require it.  
vb@130
  1901
**
vb@130
  1902
** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]
vb@130
  1903
** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite
vb@130
  1904
** and sent to the VFS after a transaction has been committed immediately
vb@130
  1905
** but before the database is unlocked. VFSes that do not need this signal
vb@130
  1906
** should silently ignore this opcode. Applications should not call
vb@130
  1907
** [sqlite3_file_control()] with this opcode as doing so may disrupt the 
vb@130
  1908
** operation of the specialized VFSes that do require it.  
vb@130
  1909
**
vb@130
  1910
** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
vb@130
  1911
** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
vb@130
  1912
** retry counts and intervals for certain disk I/O operations for the
vb@130
  1913
** windows [VFS] in order to provide robustness in the presence of
vb@130
  1914
** anti-virus programs.  By default, the windows VFS will retry file read,
vb@130
  1915
** file write, and file delete operations up to 10 times, with a delay
vb@130
  1916
** of 25 milliseconds before the first retry and with the delay increasing
vb@130
  1917
** by an additional 25 milliseconds with each subsequent retry.  This
vb@130
  1918
** opcode allows these two values (10 retries and 25 milliseconds of delay)
vb@130
  1919
** to be adjusted.  The values are changed for all database connections
vb@130
  1920
** within the same process.  The argument is a pointer to an array of two
edouard@1912
  1921
** integers where the first integer is the new retry count and the second
vb@130
  1922
** integer is the delay.  If either integer is negative, then the setting
vb@130
  1923
** is not changed but instead the prior value of that setting is written
vb@130
  1924
** into the array entry, allowing the current retry settings to be
vb@130
  1925
** interrogated.  The zDbName parameter is ignored.
vb@130
  1926
**
vb@130
  1927
** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
vb@130
  1928
** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
vb@130
  1929
** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary
dz@3192
  1930
** write ahead log ([WAL file]) and shared memory
dz@3192
  1931
** files used for transaction control
vb@130
  1932
** are automatically deleted when the latest connection to the database
vb@130
  1933
** closes.  Setting persistent WAL mode causes those files to persist after
vb@130
  1934
** close.  Persisting the files is useful when other processes that do not
vb@130
  1935
** have write permission on the directory containing the database file want
vb@130
  1936
** to read the database file, as the WAL and shared memory files must exist
vb@130
  1937
** in order for the database to be readable.  The fourth parameter to
vb@130
  1938
** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
vb@130
  1939
** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
vb@130
  1940
** WAL mode.  If the integer is -1, then it is overwritten with the current
vb@130
  1941
** WAL persistence setting.
vb@130
  1942
**
vb@130
  1943
** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
vb@130
  1944
** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
vb@130
  1945
** persistent "powersafe-overwrite" or "PSOW" setting.  The PSOW setting
vb@130
  1946
** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
vb@130
  1947
** xDeviceCharacteristics methods. The fourth parameter to
vb@130
  1948
** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
vb@130
  1949
** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
vb@130
  1950
** mode.  If the integer is -1, then it is overwritten with the current
vb@130
  1951
** zero-damage mode setting.
vb@130
  1952
**
vb@130
  1953
** <li>[[SQLITE_FCNTL_OVERWRITE]]
vb@130
  1954
** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
vb@130
  1955
** a write transaction to indicate that, unless it is rolled back for some
vb@130
  1956
** reason, the entire database file will be overwritten by the current 
vb@130
  1957
** transaction. This is used by VACUUM operations.
vb@130
  1958
**
vb@130
  1959
** <li>[[SQLITE_FCNTL_VFSNAME]]
vb@130
  1960
** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
vb@130
  1961
** all [VFSes] in the VFS stack.  The names are of all VFS shims and the
vb@130
  1962
** final bottom-level VFS are written into memory obtained from 
vb@130
  1963
** [sqlite3_malloc()] and the result is stored in the char* variable
vb@130
  1964
** that the fourth parameter of [sqlite3_file_control()] points to.
vb@130
  1965
** The caller is responsible for freeing the memory when done.  As with
vb@130
  1966
** all file-control actions, there is no guarantee that this will actually
vb@130
  1967
** do anything.  Callers should initialize the char* variable to a NULL
vb@130
  1968
** pointer in case this file-control is not implemented.  This file-control
vb@130
  1969
** is intended for diagnostic use only.
vb@130
  1970
**
Edouard@491
  1971
** <li>[[SQLITE_FCNTL_VFS_POINTER]]
Edouard@491
  1972
** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
Edouard@491
  1973
** [VFSes] currently in use.  ^(The argument X in
Edouard@491
  1974
** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
Edouard@491
  1975
** of type "[sqlite3_vfs] **".  This opcodes will set *X
Edouard@491
  1976
** to a pointer to the top-level VFS.)^
Edouard@491
  1977
** ^When there are multiple VFS shims in the stack, this opcode finds the
Edouard@491
  1978
** upper-most shim only.
Edouard@491
  1979
**
vb@130
  1980
** <li>[[SQLITE_FCNTL_PRAGMA]]
vb@130
  1981
** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 
vb@130
  1982
** file control is sent to the open [sqlite3_file] object corresponding
vb@130
  1983
** to the database file to which the pragma statement refers. ^The argument
vb@130
  1984
** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
vb@130
  1985
** pointers to strings (char**) in which the second element of the array
vb@130
  1986
** is the name of the pragma and the third element is the argument to the
vb@130
  1987
** pragma or NULL if the pragma has no argument.  ^The handler for an
vb@130
  1988
** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
vb@130
  1989
** of the char** argument point to a string obtained from [sqlite3_mprintf()]
vb@130
  1990
** or the equivalent and that string will become the result of the pragma or
vb@130
  1991
** the error message if the pragma fails. ^If the
vb@130
  1992
** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 
vb@130
  1993
** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]
vb@130
  1994
** file control returns [SQLITE_OK], then the parser assumes that the
vb@130
  1995
** VFS has handled the PRAGMA itself and the parser generates a no-op
Edouard@491
  1996
** prepared statement if result string is NULL, or that returns a copy
Edouard@491
  1997
** of the result string if the string is non-NULL.
Edouard@491
  1998
** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
vb@130
  1999
** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
vb@130
  2000
** that the VFS encountered an error while handling the [PRAGMA] and the
vb@130
  2001
** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]
vb@130
  2002
** file control occurs at the beginning of pragma statement analysis and so
vb@130
  2003
** it is able to override built-in [PRAGMA] statements.
vb@130
  2004
**
vb@130
  2005
** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
vb@130
  2006
** ^The [SQLITE_FCNTL_BUSYHANDLER]
vb@130
  2007
** file-control may be invoked by SQLite on the database file handle
vb@130
  2008
** shortly after it is opened in order to provide a custom VFS with access
vb@130
  2009
** to the connections busy-handler callback. The argument is of type (void **)
vb@130
  2010
** - an array of two (void *) values. The first (void *) actually points
vb@130
  2011
** to a function of type (int (*)(void *)). In order to invoke the connections
vb@130
  2012
** busy-handler, this function should be invoked with the second (void *) in
vb@130
  2013
** the array as the only argument. If it returns non-zero, then the operation
vb@130
  2014
** should be retried. If it returns zero, the custom VFS should abandon the
vb@130
  2015
** current operation.
vb@130
  2016
**
vb@130
  2017
** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
vb@130
  2018
** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
vb@130
  2019
** to have SQLite generate a
vb@130
  2020
** temporary filename using the same algorithm that is followed to generate
vb@130
  2021
** temporary filenames for TEMP tables and other internal uses.  The
vb@130
  2022
** argument should be a char** which will be filled with the filename
vb@130
  2023
** written into memory obtained from [sqlite3_malloc()].  The caller should
vb@130
  2024
** invoke [sqlite3_free()] on the result to avoid a memory leak.
vb@130
  2025
**
vb@130
  2026
** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
vb@130
  2027
** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the
vb@130
  2028
** maximum number of bytes that will be used for memory-mapped I/O.
vb@130
  2029
** The argument is a pointer to a value of type sqlite3_int64 that
vb@130
  2030
** is an advisory maximum number of bytes in the file to memory map.  The
vb@130
  2031
** pointer is overwritten with the old value.  The limit is not changed if
vb@130
  2032
** the value originally pointed to is negative, and so the current limit 
vb@130
  2033
** can be queried by passing in a pointer to a negative number.  This
vb@130
  2034
** file-control is used internally to implement [PRAGMA mmap_size].
vb@130
  2035
**
vb@130
  2036
** <li>[[SQLITE_FCNTL_TRACE]]
vb@130
  2037
** The [SQLITE_FCNTL_TRACE] file control provides advisory information
vb@130
  2038
** to the VFS about what the higher layers of the SQLite stack are doing.
vb@130
  2039
** This file control is used by some VFS activity tracing [shims].
vb@130
  2040
** The argument is a zero-terminated string.  Higher layers in the
vb@130
  2041
** SQLite stack may generate instances of this file control if
vb@130
  2042
** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
vb@130
  2043
**
vb@130
  2044
** <li>[[SQLITE_FCNTL_HAS_MOVED]]
vb@130
  2045
** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
vb@130
  2046
** pointer to an integer and it writes a boolean into that integer depending
vb@130
  2047
** on whether or not the file has been renamed, moved, or deleted since it
vb@130
  2048
** was first opened.
vb@130
  2049
**
edouard@1912
  2050
** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
edouard@1912
  2051
** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
edouard@1912
  2052
** underlying native file handle associated with a file handle.  This file
edouard@1912
  2053
** control interprets its argument as a pointer to a native file handle and
edouard@1912
  2054
** writes the resulting value there.
edouard@1912
  2055
**
vb@130
  2056
** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
vb@130
  2057
** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This
vb@130
  2058
** opcode causes the xFileControl method to swap the file handle with the one
vb@130
  2059
** pointed to by the pArg argument.  This capability is used during testing
vb@130
  2060
** and only needs to be supported when SQLITE_TEST is defined.
vb@130
  2061
**
Edouard@491
  2062
** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
Edouard@491
  2063
** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
Edouard@491
  2064
** be advantageous to block on the next WAL lock if the lock is not immediately
Edouard@491
  2065
** available.  The WAL subsystem issues this signal during rare
Edouard@491
  2066
** circumstances in order to fix a problem with priority inversion.
Edouard@491
  2067
** Applications should <em>not</em> use this file-control.
Edouard@491
  2068
**
Edouard@491
  2069
** <li>[[SQLITE_FCNTL_ZIPVFS]]
Edouard@491
  2070
** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
Edouard@491
  2071
** VFS should return SQLITE_NOTFOUND for this opcode.
Edouard@491
  2072
**
Edouard@491
  2073
** <li>[[SQLITE_FCNTL_RBU]]
Edouard@491
  2074
** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
Edouard@491
  2075
** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for
Edouard@491
  2076
** this opcode.  
dz@3192
  2077
**
dz@3192
  2078
** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]
dz@3192
  2079
** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then
dz@3192
  2080
** the file descriptor is placed in "batch write mode", which
dz@3192
  2081
** means all subsequent write operations will be deferred and done
dz@3192
  2082
** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].  Systems
dz@3192
  2083
** that do not support batch atomic writes will return SQLITE_NOTFOUND.
dz@3192
  2084
** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to
dz@3192
  2085
** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or
dz@3192
  2086
** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make
dz@3192
  2087
** no VFS interface calls on the same [sqlite3_file] file descriptor
dz@3192
  2088
** except for calls to the xWrite method and the xFileControl method
dz@3192
  2089
** with [SQLITE_FCNTL_SIZE_HINT].
dz@3192
  2090
**
dz@3192
  2091
** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]
dz@3192
  2092
** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write
dz@3192
  2093
** operations since the previous successful call to 
dz@3192
  2094
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.
dz@3192
  2095
** This file control returns [SQLITE_OK] if and only if the writes were
dz@3192
  2096
** all performed successfully and have been committed to persistent storage.
dz@3192
  2097
** ^Regardless of whether or not it is successful, this file control takes
dz@3192
  2098
** the file descriptor out of batch write mode so that all subsequent
dz@3192
  2099
** write operations are independent.
dz@3192
  2100
** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without
dz@3192
  2101
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
dz@3192
  2102
**
dz@3192
  2103
** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]
dz@3192
  2104
** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
dz@3192
  2105
** operations since the previous successful call to 
dz@3192
  2106
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
dz@3192
  2107
** ^This file control takes the file descriptor out of batch write mode
dz@3192
  2108
** so that all subsequent write operations are independent.
dz@3192
  2109
** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
dz@3192
  2110
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
dz@3192
  2111
**
dz@3192
  2112
** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]
dz@3192
  2113
** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain
dz@3192
  2114
** a file lock using the xLock or xShmLock methods of the VFS to wait
dz@3192
  2115
** for up to M milliseconds before failing, where M is the single 
dz@3192
  2116
** unsigned integer parameter.
dz@3192
  2117
**
dz@3192
  2118
** <li>[[SQLITE_FCNTL_DATA_VERSION]]
dz@3192
  2119
** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to
dz@3192
  2120
** a database file.  The argument is a pointer to a 32-bit unsigned integer.
dz@3192
  2121
** The "data version" for the pager is written into the pointer.  The
dz@3192
  2122
** "data version" changes whenever any change occurs to the corresponding
dz@3192
  2123
** database file, either through SQL statements on the same database
dz@3192
  2124
** connection or through transactions committed by separate database
dz@3192
  2125
** connections possibly in other processes. The [sqlite3_total_changes()]
dz@3192
  2126
** interface can be used to find if any database on the connection has changed,
dz@3192
  2127
** but that interface responds to changes on TEMP as well as MAIN and does
dz@3192
  2128
** not provide a mechanism to detect changes to MAIN only.  Also, the
dz@3192
  2129
** [sqlite3_total_changes()] interface responds to internal changes only and
dz@3192
  2130
** omits changes made by other database connections.  The
dz@3192
  2131
** [PRAGMA data_version] command provide a mechanism to detect changes to
dz@3192
  2132
** a single attached database that occur due to other database connections,
dz@3192
  2133
** but omits changes implemented by the database connection on which it is
dz@3192
  2134
** called.  This file control is the only mechanism to detect changes that
dz@3192
  2135
** happen either internally or externally and that are associated with
dz@3192
  2136
** a particular attached database.
vb@130
  2137
** </ul>
vb@130
  2138
*/
vb@130
  2139
#define SQLITE_FCNTL_LOCKSTATE               1
Edouard@491
  2140
#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
Edouard@491
  2141
#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
Edouard@491
  2142
#define SQLITE_FCNTL_LAST_ERRNO              4
vb@130
  2143
#define SQLITE_FCNTL_SIZE_HINT               5
vb@130
  2144
#define SQLITE_FCNTL_CHUNK_SIZE              6
vb@130
  2145
#define SQLITE_FCNTL_FILE_POINTER            7
vb@130
  2146
#define SQLITE_FCNTL_SYNC_OMITTED            8
vb@130
  2147
#define SQLITE_FCNTL_WIN32_AV_RETRY          9
vb@130
  2148
#define SQLITE_FCNTL_PERSIST_WAL            10
vb@130
  2149
#define SQLITE_FCNTL_OVERWRITE              11
vb@130
  2150
#define SQLITE_FCNTL_VFSNAME                12
vb@130
  2151
#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13
vb@130
  2152
#define SQLITE_FCNTL_PRAGMA                 14
vb@130
  2153
#define SQLITE_FCNTL_BUSYHANDLER            15
vb@130
  2154
#define SQLITE_FCNTL_TEMPFILENAME           16
vb@130
  2155
#define SQLITE_FCNTL_MMAP_SIZE              18
vb@130
  2156
#define SQLITE_FCNTL_TRACE                  19
vb@130
  2157
#define SQLITE_FCNTL_HAS_MOVED              20
vb@130
  2158
#define SQLITE_FCNTL_SYNC                   21
vb@130
  2159
#define SQLITE_FCNTL_COMMIT_PHASETWO        22
vb@130
  2160
#define SQLITE_FCNTL_WIN32_SET_HANDLE       23
Edouard@491
  2161
#define SQLITE_FCNTL_WAL_BLOCK              24
Edouard@491
  2162
#define SQLITE_FCNTL_ZIPVFS                 25
Edouard@491
  2163
#define SQLITE_FCNTL_RBU                    26
Edouard@491
  2164
#define SQLITE_FCNTL_VFS_POINTER            27
Edouard@491
  2165
#define SQLITE_FCNTL_JOURNAL_POINTER        28
edouard@1912
  2166
#define SQLITE_FCNTL_WIN32_GET_HANDLE       29
edouard@1912
  2167
#define SQLITE_FCNTL_PDB                    30
dz@3192
  2168
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
dz@3192
  2169
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
dz@3192
  2170
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33
dz@3192
  2171
#define SQLITE_FCNTL_LOCK_TIMEOUT           34
dz@3192
  2172
#define SQLITE_FCNTL_DATA_VERSION           35
Edouard@491
  2173
Edouard@491
  2174
/* deprecated names */
Edouard@491
  2175
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
Edouard@491
  2176
#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
Edouard@491
  2177
#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
Edouard@491
  2178
vb@130
  2179
vb@130
  2180
/*
vb@130
  2181
** CAPI3REF: Mutex Handle
vb@130
  2182
**
vb@130
  2183
** The mutex module within SQLite defines [sqlite3_mutex] to be an
vb@130
  2184
** abstract type for a mutex object.  The SQLite core never looks
vb@130
  2185
** at the internal representation of an [sqlite3_mutex].  It only
vb@130
  2186
** deals with pointers to the [sqlite3_mutex] object.
vb@130
  2187
**
vb@130
  2188
** Mutexes are created using [sqlite3_mutex_alloc()].
vb@130
  2189
*/
vb@130
  2190
typedef struct sqlite3_mutex sqlite3_mutex;
vb@130
  2191
vb@130
  2192
/*
edouard@1912
  2193
** CAPI3REF: Loadable Extension Thunk
edouard@1912
  2194
**
edouard@1912
  2195
** A pointer to the opaque sqlite3_api_routines structure is passed as
edouard@1912
  2196
** the third parameter to entry points of [loadable extensions].  This
edouard@1912
  2197
** structure must be typedefed in order to work around compiler warnings
edouard@1912
  2198
** on some platforms.
edouard@1912
  2199
*/
edouard@1912
  2200
typedef struct sqlite3_api_routines sqlite3_api_routines;
edouard@1912
  2201
edouard@1912
  2202
/*
vb@130
  2203
** CAPI3REF: OS Interface Object
vb@130
  2204
**
vb@130
  2205
** An instance of the sqlite3_vfs object defines the interface between
vb@130
  2206
** the SQLite core and the underlying operating system.  The "vfs"
vb@130
  2207
** in the name of the object stands for "virtual file system".  See
vb@130
  2208
** the [VFS | VFS documentation] for further information.
vb@130
  2209
**
dz@3192
  2210
** The VFS interface is sometimes extended by adding new methods onto
dz@3192
  2211
** the end.  Each time such an extension occurs, the iVersion field
dz@3192
  2212
** is incremented.  The iVersion value started out as 1 in
dz@3192
  2213
** SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2
dz@3192
  2214
** with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased
dz@3192
  2215
** to 3 with SQLite [version 3.7.6] on [dateof:3.7.6].  Additional fields
dz@3192
  2216
** may be appended to the sqlite3_vfs object and the iVersion value
dz@3192
  2217
** may increase again in future versions of SQLite.
dz@3192
  2218
** Note that the structure
dz@3192
  2219
** of the sqlite3_vfs object changes in the transition from
dz@3192
  2220
** SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0]
dz@3192
  2221
** and yet the iVersion field was not modified.
vb@130
  2222
**
vb@130
  2223
** The szOsFile field is the size of the subclassed [sqlite3_file]
vb@130
  2224
** structure used by this VFS.  mxPathname is the maximum length of
vb@130
  2225
** a pathname in this VFS.
vb@130
  2226
**
vb@130
  2227
** Registered sqlite3_vfs objects are kept on a linked list formed by
vb@130
  2228
** the pNext pointer.  The [sqlite3_vfs_register()]
vb@130
  2229
** and [sqlite3_vfs_unregister()] interfaces manage this list
vb@130
  2230
** in a thread-safe way.  The [sqlite3_vfs_find()] interface
vb@130
  2231
** searches the list.  Neither the application code nor the VFS
vb@130
  2232
** implementation should use the pNext pointer.
vb@130
  2233
**
vb@130
  2234
** The pNext field is the only field in the sqlite3_vfs
vb@130
  2235
** structure that SQLite will ever modify.  SQLite will only access
vb@130
  2236
** or modify this field while holding a particular static mutex.
vb@130
  2237
** The application should never modify anything within the sqlite3_vfs
vb@130
  2238
** object once the object has been registered.
vb@130
  2239
**
vb@130
  2240
** The zName field holds the name of the VFS module.  The name must
vb@130
  2241
** be unique across all VFS modules.
vb@130
  2242
**
vb@130
  2243
** [[sqlite3_vfs.xOpen]]
vb@130
  2244
** ^SQLite guarantees that the zFilename parameter to xOpen
vb@130
  2245
** is either a NULL pointer or string obtained
vb@130
  2246
** from xFullPathname() with an optional suffix added.
vb@130
  2247
** ^If a suffix is added to the zFilename parameter, it will
vb@130
  2248
** consist of a single "-" character followed by no more than
vb@130
  2249
** 11 alphanumeric and/or "-" characters.
vb@130
  2250
** ^SQLite further guarantees that
vb@130
  2251
** the string will be valid and unchanged until xClose() is
vb@130
  2252
** called. Because of the previous sentence,
vb@130
  2253
** the [sqlite3_file] can safely store a pointer to the
vb@130
  2254
** filename if it needs to remember the filename for some reason.
vb@130
  2255
** If the zFilename parameter to xOpen is a NULL pointer then xOpen
vb@130
  2256
** must invent its own temporary name for the file.  ^Whenever the 
vb@130
  2257
** xFilename parameter is NULL it will also be the case that the
vb@130
  2258
** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].
vb@130
  2259
**
vb@130
  2260
** The flags argument to xOpen() includes all bits set in
vb@130
  2261
** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]
vb@130
  2262
** or [sqlite3_open16()] is used, then flags includes at least
vb@130
  2263
** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. 
vb@130
  2264
** If xOpen() opens a file read-only then it sets *pOutFlags to
vb@130
  2265
** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.
vb@130
  2266
**
vb@130
  2267
** ^(SQLite will also add one of the following flags to the xOpen()
vb@130
  2268
** call, depending on the object being opened:
vb@130
  2269
**
vb@130
  2270
** <ul>
vb@130
  2271
** <li>  [SQLITE_OPEN_MAIN_DB]
vb@130
  2272
** <li>  [SQLITE_OPEN_MAIN_JOURNAL]
vb@130
  2273
** <li>  [SQLITE_OPEN_TEMP_DB]
vb@130
  2274
** <li>  [SQLITE_OPEN_TEMP_JOURNAL]
vb@130
  2275
** <li>  [SQLITE_OPEN_TRANSIENT_DB]
vb@130
  2276
** <li>  [SQLITE_OPEN_SUBJOURNAL]
vb@130
  2277
** <li>  [SQLITE_OPEN_MASTER_JOURNAL]
vb@130
  2278
** <li>  [SQLITE_OPEN_WAL]
vb@130
  2279
** </ul>)^
vb@130
  2280
**
vb@130
  2281
** The file I/O implementation can use the object type flags to
vb@130
  2282
** change the way it deals with files.  For example, an application
vb@130
  2283
** that does not care about crash recovery or rollback might make
vb@130
  2284
** the open of a journal file a no-op.  Writes to this journal would
vb@130
  2285
** also be no-ops, and any attempt to read the journal would return
vb@130
  2286
** SQLITE_IOERR.  Or the implementation might recognize that a database
vb@130
  2287
** file will be doing page-aligned sector reads and writes in a random
vb@130
  2288
** order and set up its I/O subsystem accordingly.
vb@130
  2289
**
vb@130
  2290
** SQLite might also add one of the following flags to the xOpen method:
vb@130
  2291
**
vb@130
  2292
** <ul>
vb@130
  2293
** <li> [SQLITE_OPEN_DELETEONCLOSE]
vb@130
  2294
** <li> [SQLITE_OPEN_EXCLUSIVE]
vb@130
  2295
** </ul>
vb@130
  2296
**
vb@130
  2297
** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
vb@130
  2298
** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]
vb@130
  2299
** will be set for TEMP databases and their journals, transient
vb@130
  2300
** databases, and subjournals.
vb@130
  2301
**
vb@130
  2302
** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction
vb@130
  2303
** with the [SQLITE_OPEN_CREATE] flag, which are both directly
vb@130
  2304
** analogous to the O_EXCL and O_CREAT flags of the POSIX open()
vb@130
  2305
** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 
vb@130
  2306
** SQLITE_OPEN_CREATE, is used to indicate that file should always
vb@130
  2307
** be created, and that it is an error if it already exists.
vb@130
  2308
** It is <i>not</i> used to indicate the file should be opened 
vb@130
  2309
** for exclusive access.
vb@130
  2310
**
vb@130
  2311
** ^At least szOsFile bytes of memory are allocated by SQLite
vb@130
  2312
** to hold the  [sqlite3_file] structure passed as the third
vb@130
  2313
** argument to xOpen.  The xOpen method does not have to
vb@130
  2314
** allocate the structure; it should just fill it in.  Note that
vb@130
  2315
** the xOpen method must set the sqlite3_file.pMethods to either
vb@130
  2316
** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do
vb@130
  2317
** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods
vb@130
  2318
** element will be valid after xOpen returns regardless of the success
vb@130
  2319
** or failure of the xOpen call.
vb@130
  2320
**
vb@130
  2321
** [[sqlite3_vfs.xAccess]]
vb@130
  2322
** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
vb@130
  2323
** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
vb@130
  2324
** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
vb@130
  2325
** to test whether a file is at least readable.   The file can be a
vb@130
  2326
** directory.
vb@130
  2327
**
vb@130
  2328
** ^SQLite will always allocate at least mxPathname+1 bytes for the
vb@130
  2329
** output buffer xFullPathname.  The exact size of the output buffer
vb@130
  2330
** is also passed as a parameter to both  methods. If the output buffer
vb@130
  2331
** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is
vb@130
  2332
** handled as a fatal error by SQLite, vfs implementations should endeavor
vb@130
  2333
** to prevent this by setting mxPathname to a sufficiently large value.
vb@130
  2334
**
vb@130
  2335
** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()
vb@130
  2336
** interfaces are not strictly a part of the filesystem, but they are
vb@130
  2337
** included in the VFS structure for completeness.
vb@130
  2338
** The xRandomness() function attempts to return nBytes bytes
vb@130
  2339
** of good-quality randomness into zOut.  The return value is
vb@130
  2340
** the actual number of bytes of randomness obtained.
vb@130
  2341
** The xSleep() method causes the calling thread to sleep for at
vb@130
  2342
** least the number of microseconds given.  ^The xCurrentTime()
vb@130
  2343
** method returns a Julian Day Number for the current date and time as
vb@130
  2344
** a floating point value.
vb@130
  2345
** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
vb@130
  2346
** Day Number multiplied by 86400000 (the number of milliseconds in 
vb@130
  2347
** a 24-hour day).  
vb@130
  2348
** ^SQLite will use the xCurrentTimeInt64() method to get the current
vb@130
  2349
** date and time if that method is available (if iVersion is 2 or 
vb@130
  2350
** greater and the function pointer is not NULL) and will fall back
vb@130
  2351
** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
vb@130
  2352
**
vb@130
  2353
** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
vb@130
  2354
** are not used by the SQLite core.  These optional interfaces are provided
vb@130
  2355
** by some VFSes to facilitate testing of the VFS code. By overriding 
vb@130
  2356
** system calls with functions under its control, a test program can
vb@130
  2357
** simulate faults and error conditions that would otherwise be difficult
vb@130
  2358
** or impossible to induce.  The set of system calls that can be overridden
vb@130
  2359
** varies from one VFS to another, and from one version of the same VFS to the
vb@130
  2360
** next.  Applications that use these interfaces must be prepared for any
vb@130
  2361
** or all of these interfaces to be NULL or for their behavior to change
vb@130
  2362
** from one release to the next.  Applications must not attempt to access
vb@130
  2363
** any of these methods if the iVersion of the VFS is less than 3.
vb@130
  2364
*/
vb@130
  2365
typedef struct sqlite3_vfs sqlite3_vfs;
vb@130
  2366
typedef void (*sqlite3_syscall_ptr)(void);
vb@130
  2367
struct sqlite3_vfs {
vb@130
  2368
  int iVersion;            /* Structure version number (currently 3) */
vb@130
  2369
  int szOsFile;            /* Size of subclassed sqlite3_file */
vb@130
  2370
  int mxPathname;          /* Maximum file pathname length */
vb@130
  2371
  sqlite3_vfs *pNext;      /* Next registered VFS */
vb@130
  2372
  const char *zName;       /* Name of this virtual file system */
vb@130
  2373
  void *pAppData;          /* Pointer to application-specific data */
vb@130
  2374
  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
vb@130
  2375
               int flags, int *pOutFlags);
vb@130
  2376
  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
vb@130
  2377
  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
vb@130
  2378
  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
vb@130
  2379
  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
vb@130
  2380
  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
vb@130
  2381
  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
vb@130
  2382
  void (*xDlClose)(sqlite3_vfs*, void*);
vb@130
  2383
  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
vb@130
  2384
  int (*xSleep)(sqlite3_vfs*, int microseconds);
vb@130
  2385
  int (*xCurrentTime)(sqlite3_vfs*, double*);
vb@130
  2386
  int (*xGetLastError)(sqlite3_vfs*, int, char *);
vb@130
  2387
  /*
vb@130
  2388
  ** The methods above are in version 1 of the sqlite_vfs object
vb@130
  2389
  ** definition.  Those that follow are added in version 2 or later
vb@130
  2390
  */
vb@130
  2391
  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
vb@130
  2392
  /*
vb@130
  2393
  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
vb@130
  2394
  ** Those below are for version 3 and greater.
vb@130
  2395
  */
vb@130
  2396
  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
vb@130
  2397
  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
vb@130
  2398
  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
vb@130
  2399
  /*
vb@130
  2400
  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
vb@716
  2401
  ** New fields may be appended in future versions.  The iVersion
vb@130
  2402
  ** value will increment whenever this happens. 
vb@130
  2403
  */
vb@130
  2404
};
vb@130
  2405
vb@130
  2406
/*
vb@130
  2407
** CAPI3REF: Flags for the xAccess VFS method
vb@130
  2408
**
vb@130
  2409
** These integer constants can be used as the third parameter to
vb@130
  2410
** the xAccess method of an [sqlite3_vfs] object.  They determine
vb@130
  2411
** what kind of permissions the xAccess method is looking for.
vb@130
  2412
** With SQLITE_ACCESS_EXISTS, the xAccess method
vb@130
  2413
** simply checks whether the file exists.
vb@130
  2414
** With SQLITE_ACCESS_READWRITE, the xAccess method
vb@130
  2415
** checks whether the named directory is both readable and writable
vb@130
  2416
** (in other words, if files can be added, removed, and renamed within
vb@130
  2417
** the directory).
vb@130
  2418
** The SQLITE_ACCESS_READWRITE constant is currently used only by the
vb@130
  2419
** [temp_store_directory pragma], though this could change in a future
vb@130
  2420
** release of SQLite.
vb@130
  2421
** With SQLITE_ACCESS_READ, the xAccess method
vb@130
  2422
** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is
vb@130
  2423
** currently unused, though it might be used in a future release of
vb@130
  2424
** SQLite.
vb@130
  2425
*/
vb@130
  2426
#define SQLITE_ACCESS_EXISTS    0
vb@130
  2427
#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */
vb@130
  2428
#define SQLITE_ACCESS_READ      2   /* Unused */
vb@130
  2429
vb@130
  2430
/*
vb@130
  2431
** CAPI3REF: Flags for the xShmLock VFS method
vb@130
  2432
**
vb@130
  2433
** These integer constants define the various locking operations
vb@130
  2434
** allowed by the xShmLock method of [sqlite3_io_methods].  The
vb@130
  2435
** following are the only legal combinations of flags to the
vb@130
  2436
** xShmLock method:
vb@130
  2437
**
vb@130
  2438
** <ul>
vb@130
  2439
** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED
vb@130
  2440
** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE
vb@130
  2441
** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED
vb@130
  2442
** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE
vb@130
  2443
** </ul>
vb@130
  2444
**
vb@130
  2445
** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
Edouard@491
  2446
** was given on the corresponding lock.  
vb@130
  2447
**
vb@130
  2448
** The xShmLock method can transition between unlocked and SHARED or
vb@130
  2449
** between unlocked and EXCLUSIVE.  It cannot transition between SHARED
vb@130
  2450
** and EXCLUSIVE.
vb@130
  2451
*/
vb@130
  2452
#define SQLITE_SHM_UNLOCK       1
vb@130
  2453
#define SQLITE_SHM_LOCK         2
vb@130
  2454
#define SQLITE_SHM_SHARED       4
vb@130
  2455
#define SQLITE_SHM_EXCLUSIVE    8
vb@130
  2456
vb@130
  2457
/*
vb@130
  2458
** CAPI3REF: Maximum xShmLock index
vb@130
  2459
**
vb@130
  2460
** The xShmLock method on [sqlite3_io_methods] may use values
vb@130
  2461
** between 0 and this upper bound as its "offset" argument.
vb@130
  2462
** The SQLite core will never attempt to acquire or release a
vb@130
  2463
** lock outside of this range
vb@130
  2464
*/
vb@130
  2465
#define SQLITE_SHM_NLOCK        8
vb@130
  2466
vb@130
  2467
vb@130
  2468
/*
vb@130
  2469
** CAPI3REF: Initialize The SQLite Library
vb@130
  2470
**
vb@130
  2471
** ^The sqlite3_initialize() routine initializes the
vb@130
  2472
** SQLite library.  ^The sqlite3_shutdown() routine
vb@130
  2473
** deallocates any resources that were allocated by sqlite3_initialize().
vb@130
  2474
** These routines are designed to aid in process initialization and
vb@130
  2475
** shutdown on embedded systems.  Workstation applications using
vb@130
  2476
** SQLite normally do not need to invoke either of these routines.
vb@130
  2477
**
vb@130
  2478
** A call to sqlite3_initialize() is an "effective" call if it is
vb@130
  2479
** the first time sqlite3_initialize() is invoked during the lifetime of
vb@130
  2480
** the process, or if it is the first time sqlite3_initialize() is invoked
vb@130
  2481
** following a call to sqlite3_shutdown().  ^(Only an effective call
vb@130
  2482
** of sqlite3_initialize() does any initialization.  All other calls
vb@130
  2483
** are harmless no-ops.)^
vb@130
  2484
**
vb@130
  2485
** A call to sqlite3_shutdown() is an "effective" call if it is the first
vb@130
  2486
** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only
vb@130
  2487
** an effective call to sqlite3_shutdown() does any deinitialization.
vb@130
  2488
** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
vb@130
  2489
**
vb@130
  2490
** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
vb@130
  2491
** is not.  The sqlite3_shutdown() interface must only be called from a
vb@130
  2492
** single thread.  All open [database connections] must be closed and all
vb@130
  2493
** other SQLite resources must be deallocated prior to invoking
vb@130
  2494
** sqlite3_shutdown().
vb@130
  2495
**
vb@130
  2496
** Among other things, ^sqlite3_initialize() will invoke
vb@130
  2497
** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()
vb@130
  2498
** will invoke sqlite3_os_end().
vb@130
  2499
**
vb@130
  2500
** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
vb@130
  2501
** ^If for some reason, sqlite3_initialize() is unable to initialize
vb@130
  2502
** the library (perhaps it is unable to allocate a needed resource such
vb@130
  2503
** as a mutex) it returns an [error code] other than [SQLITE_OK].
vb@130
  2504
**
vb@130
  2505
** ^The sqlite3_initialize() routine is called internally by many other
vb@130
  2506
** SQLite interfaces so that an application usually does not need to
vb@130
  2507
** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]
vb@130
  2508
** calls sqlite3_initialize() so the SQLite library will be automatically
vb@130
  2509
** initialized when [sqlite3_open()] is called if it has not be initialized
vb@130
  2510
** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
vb@130
  2511
** compile-time option, then the automatic calls to sqlite3_initialize()
vb@130
  2512
** are omitted and the application must call sqlite3_initialize() directly
vb@130
  2513
** prior to using any other SQLite interface.  For maximum portability,
vb@130
  2514
** it is recommended that applications always invoke sqlite3_initialize()
vb@130
  2515
** directly prior to using any other SQLite interface.  Future releases
vb@130
  2516
** of SQLite may require this.  In other words, the behavior exhibited
vb@130
  2517
** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the
vb@130
  2518
** default behavior in some future release of SQLite.
vb@130
  2519
**
vb@130
  2520
** The sqlite3_os_init() routine does operating-system specific
vb@130
  2521
** initialization of the SQLite library.  The sqlite3_os_end()
vb@130
  2522
** routine undoes the effect of sqlite3_os_init().  Typical tasks
vb@130
  2523
** performed by these routines include allocation or deallocation
vb@130
  2524
** of static resources, initialization of global variables,
vb@130
  2525
** setting up a default [sqlite3_vfs] module, or setting up
vb@130
  2526
** a default configuration using [sqlite3_config()].
vb@130
  2527
**
vb@130
  2528
** The application should never invoke either sqlite3_os_init()
vb@130
  2529
** or sqlite3_os_end() directly.  The application should only invoke
vb@130
  2530
** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()
vb@130
  2531
** interface is called automatically by sqlite3_initialize() and
vb@130
  2532
** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate
vb@130
  2533
** implementations for sqlite3_os_init() and sqlite3_os_end()
vb@130
  2534
** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
vb@130
  2535
** When [custom builds | built for other platforms]
vb@130
  2536
** (using the [SQLITE_OS_OTHER=1] compile-time
vb@130
  2537
** option) the application must supply a suitable implementation for
vb@130
  2538
** sqlite3_os_init() and sqlite3_os_end().  An application-supplied
vb@130
  2539
** implementation of sqlite3_os_init() or sqlite3_os_end()
vb@130
  2540
** must return [SQLITE_OK] on success and some other [error code] upon
vb@130
  2541
** failure.
vb@130
  2542
*/
edouard@1912
  2543
SQLITE_API int sqlite3_initialize(void);
edouard@1912
  2544
SQLITE_API int sqlite3_shutdown(void);
edouard@1912
  2545
SQLITE_API int sqlite3_os_init(void);
edouard@1912
  2546
SQLITE_API int sqlite3_os_end(void);
vb@130
  2547
vb@130
  2548
/*
vb@130
  2549
** CAPI3REF: Configuring The SQLite Library
vb@130
  2550
**
vb@130
  2551
** The sqlite3_config() interface is used to make global configuration
vb@130
  2552
** changes to SQLite in order to tune SQLite to the specific needs of
vb@130
  2553
** the application.  The default configuration is recommended for most
vb@130
  2554
** applications and so this routine is usually not necessary.  It is
vb@130
  2555
** provided to support rare applications with unusual needs.
vb@130
  2556
**
Edouard@491
  2557
** <b>The sqlite3_config() interface is not threadsafe. The application
Edouard@491
  2558
** must ensure that no other SQLite interfaces are invoked by other
Edouard@491
  2559
** threads while sqlite3_config() is running.</b>
Edouard@491
  2560
**
Edouard@491
  2561
** The sqlite3_config() interface
vb@130
  2562
** may only be invoked prior to library initialization using
vb@130
  2563
** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
vb@130
  2564
** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
vb@130
  2565
** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
vb@130
  2566
** Note, however, that ^sqlite3_config() can be called as part of the
vb@130
  2567
** implementation of an application-defined [sqlite3_os_init()].
vb@130
  2568
**
vb@130
  2569
** The first argument to sqlite3_config() is an integer
vb@130
  2570
** [configuration option] that determines
vb@130
  2571
** what property of SQLite is to be configured.  Subsequent arguments
vb@130
  2572
** vary depending on the [configuration option]
vb@130
  2573
** in the first argument.
vb@130
  2574
**
vb@130
  2575
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
vb@130
  2576
** ^If the option is unknown or SQLite is unable to set the option
vb@130
  2577
** then this routine returns a non-zero [error code].
vb@130
  2578
*/
edouard@1912
  2579
SQLITE_API int sqlite3_config(int, ...);
vb@130
  2580
vb@130
  2581
/*
vb@130
  2582
** CAPI3REF: Configure database connections
Edouard@491
  2583
** METHOD: sqlite3
vb@130
  2584
**
vb@130
  2585
** The sqlite3_db_config() interface is used to make configuration
vb@130
  2586
** changes to a [database connection].  The interface is similar to
vb@130
  2587
** [sqlite3_config()] except that the changes apply to a single
vb@130
  2588
** [database connection] (specified in the first argument).
vb@130
  2589
**
vb@130
  2590
** The second argument to sqlite3_db_config(D,V,...)  is the
vb@130
  2591
** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code 
vb@130
  2592
** that indicates what aspect of the [database connection] is being configured.
vb@130
  2593
** Subsequent arguments vary depending on the configuration verb.
vb@130
  2594
**
vb@130
  2595
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
vb@130
  2596
** the call is considered successful.
vb@130
  2597
*/
edouard@1912
  2598
SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
vb@130
  2599
vb@130
  2600
/*
vb@130
  2601
** CAPI3REF: Memory Allocation Routines
vb@130
  2602
**
vb@130
  2603
** An instance of this object defines the interface between SQLite
vb@130
  2604
** and low-level memory allocation routines.
vb@130
  2605
**
vb@130
  2606
** This object is used in only one place in the SQLite interface.
vb@130
  2607
** A pointer to an instance of this object is the argument to
vb@130
  2608
** [sqlite3_config()] when the configuration option is
vb@130
  2609
** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  
vb@130
  2610
** By creating an instance of this object
vb@130
  2611
** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
vb@130
  2612
** during configuration, an application can specify an alternative
vb@130
  2613
** memory allocation subsystem for SQLite to use for all of its
vb@130
  2614
** dynamic memory needs.
vb@130
  2615
**
vb@130
  2616
** Note that SQLite comes with several [built-in memory allocators]
vb@130
  2617
** that are perfectly adequate for the overwhelming majority of applications
vb@130
  2618
** and that this object is only useful to a tiny minority of applications
vb@130
  2619
** with specialized memory allocation requirements.  This object is
vb@130
  2620
** also used during testing of SQLite in order to specify an alternative
vb@130
  2621
** memory allocator that simulates memory out-of-memory conditions in
vb@130
  2622
** order to verify that SQLite recovers gracefully from such
vb@130
  2623
** conditions.
vb@130
  2624
**
vb@130
  2625
** The xMalloc, xRealloc, and xFree methods must work like the
vb@130
  2626
** malloc(), realloc() and free() functions from the standard C library.
vb@130
  2627
** ^SQLite guarantees that the second argument to
vb@130
  2628
** xRealloc is always a value returned by a prior call to xRoundup.
vb@130
  2629
**
vb@130
  2630
** xSize should return the allocated size of a memory allocation
vb@130
  2631
** previously obtained from xMalloc or xRealloc.  The allocated size
vb@130
  2632
** is always at least as big as the requested size but may be larger.
vb@130
  2633
**
vb@130
  2634
** The xRoundup method returns what would be the allocated size of
vb@130
  2635
** a memory allocation given a particular requested size.  Most memory
vb@130
  2636
** allocators round up memory allocations at least to the next multiple
vb@130
  2637
** of 8.  Some allocators round up to a larger multiple or to a power of 2.
vb@130
  2638
** Every memory allocation request coming in through [sqlite3_malloc()]
vb@130
  2639
** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, 
vb@130
  2640
** that causes the corresponding memory allocation to fail.
vb@130
  2641
**
vb@130
  2642
** The xInit method initializes the memory allocator.  For example,
vb@130
  2643
** it might allocate any require mutexes or initialize internal data
vb@130
  2644
** structures.  The xShutdown method is invoked (indirectly) by
vb@130
  2645
** [sqlite3_shutdown()] and should deallocate any resources acquired
vb@130
  2646
** by xInit.  The pAppData pointer is used as the only parameter to
vb@130
  2647
** xInit and xShutdown.
vb@130
  2648
**
vb@130
  2649
** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
vb@130
  2650
** the xInit method, so the xInit method need not be threadsafe.  The
vb@130
  2651
** xShutdown method is only called from [sqlite3_shutdown()] so it does
vb@130
  2652
** not need to be threadsafe either.  For all other methods, SQLite
vb@130
  2653
** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the
vb@130
  2654
** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which
vb@130
  2655
** it is by default) and so the methods are automatically serialized.
vb@130
  2656
** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other
vb@130
  2657
** methods must be threadsafe or else make their own arrangements for
vb@130
  2658
** serialization.
vb@130
  2659
**
vb@130
  2660
** SQLite will never invoke xInit() more than once without an intervening
vb@130
  2661
** call to xShutdown().
vb@130
  2662
*/
vb@130
  2663
typedef struct sqlite3_mem_methods sqlite3_mem_methods;
vb@130
  2664
struct sqlite3_mem_methods {
vb@130
  2665
  void *(*xMalloc)(int);         /* Memory allocation function */
vb@130
  2666
  void (*xFree)(void*);          /* Free a prior allocation */
vb@130
  2667
  void *(*xRealloc)(void*,int);  /* Resize an allocation */
vb@130
  2668
  int (*xSize)(void*);           /* Return the size of an allocation */
vb@130
  2669
  int (*xRoundup)(int);          /* Round up request size to allocation size */
vb@130
  2670
  int (*xInit)(void*);           /* Initialize the memory allocator */
vb@130
  2671
  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
vb@130
  2672
  void *pAppData;                /* Argument to xInit() and xShutdown() */
vb@130
  2673
};
vb@130
  2674
vb@130
  2675
/*
vb@130
  2676
** CAPI3REF: Configuration Options
vb@130
  2677
** KEYWORDS: {configuration option}
vb@130
  2678
**
vb@130
  2679
** These constants are the available integer configuration options that
vb@130
  2680
** can be passed as the first argument to the [sqlite3_config()] interface.
vb@130
  2681
**
vb@130
  2682
** New configuration options may be added in future releases of SQLite.
vb@130
  2683
** Existing configuration options might be discontinued.  Applications
vb@130
  2684
** should check the return code from [sqlite3_config()] to make sure that
vb@130
  2685
** the call worked.  The [sqlite3_config()] interface will return a
vb@130
  2686
** non-zero [error code] if a discontinued or unsupported configuration option
vb@130
  2687
** is invoked.
vb@130
  2688
**
vb@130
  2689
** <dl>
vb@130
  2690
** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
vb@130
  2691
** <dd>There are no arguments to this option.  ^This option sets the
vb@130
  2692
** [threading mode] to Single-thread.  In other words, it disables
vb@130
  2693
** all mutexing and puts SQLite into a mode where it can only be used
vb@130
  2694
** by a single thread.   ^If SQLite is compiled with
vb@130
  2695
** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
vb@130
  2696
** it is not possible to change the [threading mode] from its default
vb@130
  2697
** value of Single-thread and so [sqlite3_config()] will return 
vb@130
  2698
** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
vb@130
  2699
** configuration option.</dd>
vb@130
  2700
**
vb@130
  2701
** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>
vb@130
  2702
** <dd>There are no arguments to this option.  ^This option sets the
vb@130
  2703
** [threading mode] to Multi-thread.  In other words, it disables
vb@130
  2704
** mutexing on [database connection] and [prepared statement] objects.
vb@130
  2705
** The application is responsible for serializing access to
vb@130
  2706
** [database connections] and [prepared statements].  But other mutexes
vb@130
  2707
** are enabled so that SQLite will be safe to use in a multi-threaded
vb@130
  2708
** environment as long as no two threads attempt to use the same
vb@130
  2709
** [database connection] at the same time.  ^If SQLite is compiled with
vb@130
  2710
** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
vb@130
  2711
** it is not possible to set the Multi-thread [threading mode] and
vb@130
  2712
** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
vb@130
  2713
** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
vb@130
  2714
**
vb@130
  2715
** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>
vb@130
  2716
** <dd>There are no arguments to this option.  ^This option sets the
vb@130
  2717
** [threading mode] to Serialized. In other words, this option enables
vb@130
  2718
** all mutexes including the recursive
vb@130
  2719
** mutexes on [database connection] and [prepared statement] objects.
vb@130
  2720
** In this mode (which is the default when SQLite is compiled with
vb@130
  2721
** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
vb@130
  2722
** to [database connections] and [prepared statements] so that the
vb@130
  2723
** application is free to use the same [database connection] or the
vb@130
  2724
** same [prepared statement] in different threads at the same time.
vb@130
  2725
** ^If SQLite is compiled with
vb@130
  2726
** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
vb@130
  2727
** it is not possible to set the Serialized [threading mode] and
vb@130
  2728
** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
vb@130
  2729
** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
vb@130
  2730
**
vb@130
  2731
** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
Edouard@491
  2732
** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is 
Edouard@491
  2733
** a pointer to an instance of the [sqlite3_mem_methods] structure.
Edouard@491
  2734
** The argument specifies
vb@130
  2735
** alternative low-level memory allocation routines to be used in place of
vb@130
  2736
** the memory allocation routines built into SQLite.)^ ^SQLite makes
vb@130
  2737
** its own private copy of the content of the [sqlite3_mem_methods] structure
vb@130
  2738
** before the [sqlite3_config()] call returns.</dd>
vb@130
  2739
**
vb@130
  2740
** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
Edouard@491
  2741
** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
Edouard@491
  2742
** is a pointer to an instance of the [sqlite3_mem_methods] structure.
Edouard@491
  2743
** The [sqlite3_mem_methods]
vb@130
  2744
** structure is filled with the currently defined memory allocation routines.)^
vb@130
  2745
** This option can be used to overload the default memory allocation
vb@130
  2746
** routines with a wrapper that simulations memory allocation failure or
vb@130
  2747
** tracks memory usage, for example. </dd>
vb@130
  2748
**
dz@3192
  2749
** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>