1.1 --- a/extensions/sqlite/sqlite-source/sqlite3.h Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,3552 +0,0 @@
1.4 -/*
1.5 -** 2001 September 15
1.6 -**
1.7 -** The author disclaims copyright to this source code. In place of
1.8 -** a legal notice, here is a blessing:
1.9 -**
1.10 -** May you do good and not evil.
1.11 -** May you find forgiveness for yourself and forgive others.
1.12 -** May you share freely, never taking more than you give.
1.13 -**
1.14 -*************************************************************************
1.15 -** This header file defines the interface that the SQLite library
1.16 -** presents to client programs. If a C-function, structure, datatype,
1.17 -** or constant definition does not appear in this file, then it is
1.18 -** not a published API of SQLite, is subject to change without
1.19 -** notice, and should not be referenced by programs that use SQLite.
1.20 -**
1.21 -** Some of the definitions that are in this file are marked as
1.22 -** "experimental". Experimental interfaces are normally new
1.23 -** features recently added to SQLite. We do not anticipate changes
1.24 -** to experimental interfaces but reserve to make minor changes if
1.25 -** experience from use "in the wild" suggest such changes are prudent.
1.26 -**
1.27 -** The official C-language API documentation for SQLite is derived
1.28 -** from comments in this file. This file is the authoritative source
1.29 -** on how SQLite interfaces are suppose to operate.
1.30 -**
1.31 -** The name of this file under configuration management is "sqlite.h.in".
1.32 -** The makefile makes some minor changes to this file (such as inserting
1.33 -** the version number) and changes its name to "sqlite3.h" as
1.34 -** part of the build process.
1.35 -**
1.36 -** @(#) $Id$
1.37 -*/
1.38 -#ifndef _SQLITE3_H_
1.39 -#define _SQLITE3_H_
1.40 -#include <stdarg.h> /* Needed for the definition of va_list */
1.41 -
1.42 -/*
1.43 -** Make sure we can call this stuff from C++.
1.44 -*/
1.45 -#ifdef __cplusplus
1.46 -extern "C" {
1.47 -#endif
1.48 -
1.49 -
1.50 -/*
1.51 -** Add the ability to override 'extern'
1.52 -*/
1.53 -#ifndef SQLITE_EXTERN
1.54 -# define SQLITE_EXTERN extern
1.55 -#endif
1.56 -
1.57 -/*
1.58 -** Make sure these symbols where not defined by some previous header
1.59 -** file.
1.60 -*/
1.61 -#ifdef SQLITE_VERSION
1.62 -# undef SQLITE_VERSION
1.63 -#endif
1.64 -#ifdef SQLITE_VERSION_NUMBER
1.65 -# undef SQLITE_VERSION_NUMBER
1.66 -#endif
1.67 -
1.68 -/*
1.69 -** CAPI3REF: Compile-Time Library Version Numbers
1.70 -**
1.71 -** The version of the SQLite library is contained in the sqlite3.h
1.72 -** header file in a #define named SQLITE_VERSION. The SQLITE_VERSION
1.73 -** macro resolves to a string constant.
1.74 -**
1.75 -** The format of the version string is "X.Y.Z", where
1.76 -** X is the major version number, Y is the minor version number and Z
1.77 -** is the release number. The X.Y.Z might be followed by "alpha" or "beta".
1.78 -** For example "3.1.1beta".
1.79 -**
1.80 -** The X value is always 3 in SQLite. The X value only changes when
1.81 -** backwards compatibility is broken and we intend to never break
1.82 -** backwards compatibility. The Y value only changes when
1.83 -** there are major feature enhancements that are forwards compatible
1.84 -** but not backwards compatible. The Z value is incremented with
1.85 -** each release but resets back to 0 when Y is incremented.
1.86 -**
1.87 -** The SQLITE_VERSION_NUMBER is an integer with the value
1.88 -** (X*1000000 + Y*1000 + Z). For example, for version "3.1.1beta",
1.89 -** SQLITE_VERSION_NUMBER is set to 3001001. To detect if they are using
1.90 -** version 3.1.1 or greater at compile time, programs may use the test
1.91 -** (SQLITE_VERSION_NUMBER>=3001001).
1.92 -**
1.93 -** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].
1.94 -*/
1.95 -#define SQLITE_VERSION "3.5.1"
1.96 -#define SQLITE_VERSION_NUMBER 3005001
1.97 -
1.98 -/*
1.99 -** CAPI3REF: Run-Time Library Version Numbers
1.100 -**
1.101 -** These routines return values equivalent to the header constants
1.102 -** [SQLITE_VERSION] and [SQLITE_VERSION_NUMBER]. The values returned
1.103 -** by this routines should only be different from the header values
1.104 -** if you compile your program using an sqlite3.h header from a
1.105 -** different version of SQLite that the version of the library you
1.106 -** link against.
1.107 -**
1.108 -** The sqlite3_version[] string constant contains the text of the
1.109 -** [SQLITE_VERSION] string. The sqlite3_libversion() function returns
1.110 -** a poiner to the sqlite3_version[] string constant. The function
1.111 -** is provided for DLL users who can only access functions and not
1.112 -** constants within the DLL.
1.113 -*/
1.114 -SQLITE_EXTERN const char sqlite3_version[];
1.115 -const char *sqlite3_libversion(void);
1.116 -int sqlite3_libversion_number(void);
1.117 -
1.118 -/*
1.119 -** CAPI3REF: Test To See If The Library Is Threadsafe
1.120 -**
1.121 -** This routine returns TRUE (nonzero) if SQLite was compiled with
1.122 -** all of its mutexes enabled and is thus threadsafe. It returns
1.123 -** zero if the particular build is for single-threaded operation
1.124 -** only.
1.125 -**
1.126 -** Really all this routine does is return true if SQLite was compiled
1.127 -** with the -DSQLITE_THREADSAFE=1 option and false if
1.128 -** compiled with -DSQLITE_THREADSAFE=0. If SQLite uses an
1.129 -** application-defined mutex subsystem, malloc subsystem, collating
1.130 -** sequence, VFS, SQL function, progress callback, commit hook,
1.131 -** extension, or other accessories and these add-ons are not
1.132 -** threadsafe, then clearly the combination will not be threadsafe
1.133 -** either. Hence, this routine never reports that the library
1.134 -** is guaranteed to be threadsafe, only when it is guaranteed not
1.135 -** to be.
1.136 -**
1.137 -** This is an experimental API and may go away or change in future
1.138 -** releases.
1.139 -*/
1.140 -int sqlite3_threadsafe(void);
1.141 -
1.142 -/*
1.143 -** CAPI3REF: Database Connection Handle
1.144 -**
1.145 -** Each open SQLite database is represented by pointer to an instance of the
1.146 -** opaque structure named "sqlite3". It is useful to think of an sqlite3
1.147 -** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
1.148 -** [sqlite3_open_v2()] interfaces are its constructors
1.149 -** and [sqlite3_close()] is its destructor. There are many other interfaces
1.150 -** (such as [sqlite3_prepare_v2()], [sqlite3_create_function()], and
1.151 -** [sqlite3_busy_timeout()] to name but three) that are methods on this
1.152 -** object.
1.153 -*/
1.154 -typedef struct sqlite3 sqlite3;
1.155 -
1.156 -
1.157 -/*
1.158 -** CAPI3REF: 64-Bit Integer Types
1.159 -**
1.160 -** Some compilers do not support the "long long" datatype. So we have
1.161 -** to do compiler-specific typedefs for 64-bit signed and unsigned integers.
1.162 -**
1.163 -** Many SQLite interface functions require a 64-bit integer arguments.
1.164 -** Those interfaces are declared using this typedef.
1.165 -*/
1.166 -#ifdef SQLITE_INT64_TYPE
1.167 - typedef SQLITE_INT64_TYPE sqlite_int64;
1.168 - typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
1.169 -#elif defined(_MSC_VER) || defined(__BORLANDC__)
1.170 - typedef __int64 sqlite_int64;
1.171 - typedef unsigned __int64 sqlite_uint64;
1.172 -#else
1.173 - typedef long long int sqlite_int64;
1.174 - typedef unsigned long long int sqlite_uint64;
1.175 -#endif
1.176 -typedef sqlite_int64 sqlite3_int64;
1.177 -typedef sqlite_uint64 sqlite3_uint64;
1.178 -
1.179 -/*
1.180 -** If compiling for a processor that lacks floating point support,
1.181 -** substitute integer for floating-point
1.182 -*/
1.183 -#ifdef SQLITE_OMIT_FLOATING_POINT
1.184 -# define double sqlite3_int64
1.185 -#endif
1.186 -
1.187 -/*
1.188 -** CAPI3REF: Closing A Database Connection
1.189 -**
1.190 -** Call this function with a pointer to a structure that was previously
1.191 -** returned from [sqlite3_open()], [sqlite3_open16()], or
1.192 -** [sqlite3_open_v2()] and the corresponding database will by
1.193 -** closed.
1.194 -**
1.195 -** All SQL statements prepared using [sqlite3_prepare_v2()] or
1.196 -** [sqlite3_prepare16_v2()] must be destroyed using [sqlite3_finalize()]
1.197 -** before this routine is called. Otherwise, SQLITE_BUSY is returned and the
1.198 -** database connection remains open.
1.199 -**
1.200 -** Passing this routine a database connection that has already been
1.201 -** closed results in undefined behavior. If other interfaces that
1.202 -** reference the same database connection are pending (either in the
1.203 -** same thread or in different threads) when this routine is called,
1.204 -** then the behavior is undefined and is almost certainly undesirable.
1.205 -*/
1.206 -int sqlite3_close(sqlite3 *);
1.207 -
1.208 -/*
1.209 -** The type for a callback function.
1.210 -** This is legacy and deprecated. It is included for historical
1.211 -** compatibility and is not documented.
1.212 -*/
1.213 -typedef int (*sqlite3_callback)(void*,int,char**, char**);
1.214 -
1.215 -/*
1.216 -** CAPI3REF: One-Step Query Execution Interface
1.217 -**
1.218 -** This interface is used to do a one-time evaluatation of zero
1.219 -** or more SQL statements. UTF-8 text of the SQL statements to
1.220 -** be evaluted is passed in as the second parameter. The statements
1.221 -** are prepared one by one using [sqlite3_prepare()], evaluated
1.222 -** using [sqlite3_step()], then destroyed using [sqlite3_finalize()].
1.223 -**
1.224 -** If one or more of the SQL statements are queries, then
1.225 -** the callback function specified by the 3rd parameter is
1.226 -** invoked once for each row of the query result. This callback
1.227 -** should normally return 0. If the callback returns a non-zero
1.228 -** value then the query is aborted, all subsequent SQL statements
1.229 -** are skipped and the sqlite3_exec() function returns the [SQLITE_ABORT].
1.230 -**
1.231 -** The 4th parameter to this interface is an arbitrary pointer that is
1.232 -** passed through to the callback function as its first parameter.
1.233 -**
1.234 -** The 2nd parameter to the callback function is the number of
1.235 -** columns in the query result. The 3rd parameter to the callback
1.236 -** is an array of strings holding the values for each column
1.237 -** as extracted using [sqlite3_column_text()].
1.238 -** The 4th parameter to the callback is an array of strings
1.239 -** obtained using [sqlite3_column_name()] and holding
1.240 -** the names of each column.
1.241 -**
1.242 -** The callback function may be NULL, even for queries. A NULL
1.243 -** callback is not an error. It just means that no callback
1.244 -** will be invoked.
1.245 -**
1.246 -** If an error occurs while parsing or evaluating the SQL (but
1.247 -** not while executing the callback) then an appropriate error
1.248 -** message is written into memory obtained from [sqlite3_malloc()] and
1.249 -** *errmsg is made to point to that message. The calling function
1.250 -** is responsible for freeing the memory using [sqlite3_free()].
1.251 -** If errmsg==NULL, then no error message is ever written.
1.252 -**
1.253 -** The return value is is SQLITE_OK if there are no errors and
1.254 -** some other [SQLITE_OK | return code] if there is an error.
1.255 -** The particular return value depends on the type of error.
1.256 -**
1.257 -*/
1.258 -int sqlite3_exec(
1.259 - sqlite3*, /* An open database */
1.260 - const char *sql, /* SQL to be evaluted */
1.261 - int (*callback)(void*,int,char**,char**), /* Callback function */
1.262 - void *, /* 1st argument to callback */
1.263 - char **errmsg /* Error msg written here */
1.264 -);
1.265 -
1.266 -/*
1.267 -** CAPI3REF: Result Codes
1.268 -** KEYWORDS: SQLITE_OK
1.269 -**
1.270 -** Many SQLite functions return an integer result code from the set shown
1.271 -** above in order to indicates success or failure.
1.272 -**
1.273 -** The result codes above are the only ones returned by SQLite in its
1.274 -** default configuration. However, the [sqlite3_extended_result_codes()]
1.275 -** API can be used to set a database connectoin to return more detailed
1.276 -** result codes.
1.277 -**
1.278 -** See also: [SQLITE_IOERR_READ | extended result codes]
1.279 -**
1.280 -*/
1.281 -#define SQLITE_OK 0 /* Successful result */
1.282 -/* beginning-of-error-codes */
1.283 -#define SQLITE_ERROR 1 /* SQL error or missing database */
1.284 -#define SQLITE_INTERNAL 2 /* NOT USED. Internal logic error in SQLite */
1.285 -#define SQLITE_PERM 3 /* Access permission denied */
1.286 -#define SQLITE_ABORT 4 /* Callback routine requested an abort */
1.287 -#define SQLITE_BUSY 5 /* The database file is locked */
1.288 -#define SQLITE_LOCKED 6 /* A table in the database is locked */
1.289 -#define SQLITE_NOMEM 7 /* A malloc() failed */
1.290 -#define SQLITE_READONLY 8 /* Attempt to write a readonly database */
1.291 -#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/
1.292 -#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
1.293 -#define SQLITE_CORRUPT 11 /* The database disk image is malformed */
1.294 -#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */
1.295 -#define SQLITE_FULL 13 /* Insertion failed because database is full */
1.296 -#define SQLITE_CANTOPEN 14 /* Unable to open the database file */
1.297 -#define SQLITE_PROTOCOL 15 /* NOT USED. Database lock protocol error */
1.298 -#define SQLITE_EMPTY 16 /* Database is empty */
1.299 -#define SQLITE_SCHEMA 17 /* The database schema changed */
1.300 -#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */
1.301 -#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */
1.302 -#define SQLITE_MISMATCH 20 /* Data type mismatch */
1.303 -#define SQLITE_MISUSE 21 /* Library used incorrectly */
1.304 -#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
1.305 -#define SQLITE_AUTH 23 /* Authorization denied */
1.306 -#define SQLITE_FORMAT 24 /* Auxiliary database format error */
1.307 -#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
1.308 -#define SQLITE_NOTADB 26 /* File opened that is not a database file */
1.309 -#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
1.310 -#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
1.311 -/* end-of-error-codes */
1.312 -
1.313 -/*
1.314 -** CAPI3REF: Extended Result Codes
1.315 -**
1.316 -** In its default configuration, SQLite API routines return one of 26 integer
1.317 -** result codes described at result-codes. However, experience has shown that
1.318 -** many of these result codes are too course-grained. They do not provide as
1.319 -** much information about problems as users might like. In an effort to
1.320 -** address this, newer versions of SQLite (version 3.3.8 and later) include
1.321 -** support for additional result codes that provide more detailed information
1.322 -** about errors. The extended result codes are enabled (or disabled) for
1.323 -** each database
1.324 -** connection using the [sqlite3_extended_result_codes()] API.
1.325 -**
1.326 -** Some of the available extended result codes are listed above.
1.327 -** We expect the number of extended result codes will be expand
1.328 -** over time. Software that uses extended result codes should expect
1.329 -** to see new result codes in future releases of SQLite.
1.330 -**
1.331 -** The symbolic name for an extended result code always contains a related
1.332 -** primary result code as a prefix. Primary result codes contain a single
1.333 -** "_" character. Extended result codes contain two or more "_" characters.
1.334 -** The numeric value of an extended result code can be converted to its
1.335 -** corresponding primary result code by masking off the lower 8 bytes.
1.336 -**
1.337 -** The SQLITE_OK result code will never be extended. It will always
1.338 -** be exactly zero.
1.339 -*/
1.340 -#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
1.341 -#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
1.342 -#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
1.343 -#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
1.344 -#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
1.345 -#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
1.346 -#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
1.347 -#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
1.348 -#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
1.349 -#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
1.350 -#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
1.351 -#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
1.352 -
1.353 -/*
1.354 -** CAPI3REF: Flags For File Open Operations
1.355 -**
1.356 -** Combination of the following bit values are used as the
1.357 -** third argument to the [sqlite3_open_v2()] interface and
1.358 -** as fourth argument to the xOpen method of the
1.359 -** [sqlite3_vfs] object.
1.360 -**
1.361 -*/
1.362 -#define SQLITE_OPEN_READONLY 0x00000001
1.363 -#define SQLITE_OPEN_READWRITE 0x00000002
1.364 -#define SQLITE_OPEN_CREATE 0x00000004
1.365 -#define SQLITE_OPEN_DELETEONCLOSE 0x00000008
1.366 -#define SQLITE_OPEN_EXCLUSIVE 0x00000010
1.367 -#define SQLITE_OPEN_MAIN_DB 0x00000100
1.368 -#define SQLITE_OPEN_TEMP_DB 0x00000200
1.369 -#define SQLITE_OPEN_TRANSIENT_DB 0x00000400
1.370 -#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800
1.371 -#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000
1.372 -#define SQLITE_OPEN_SUBJOURNAL 0x00002000
1.373 -#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000
1.374 -
1.375 -/*
1.376 -** CAPI3REF: Device Characteristics
1.377 -**
1.378 -** The xDeviceCapabilities method of the [sqlite3_io_methods]
1.379 -** object returns an integer which is a vector of the following
1.380 -** bit values expressing I/O characteristics of the mass storage
1.381 -** device that holds the file that the [sqlite3_io_methods]
1.382 -** refers to.
1.383 -**
1.384 -** The SQLITE_IOCAP_ATOMIC property means that all writes of
1.385 -** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
1.386 -** mean that writes of blocks that are nnn bytes in size and
1.387 -** are aligned to an address which is an integer multiple of
1.388 -** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
1.389 -** that when data is appended to a file, the data is appended
1.390 -** first then the size of the file is extended, never the other
1.391 -** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
1.392 -** information is written to disk in the same order as calls
1.393 -** to xWrite().
1.394 -*/
1.395 -#define SQLITE_IOCAP_ATOMIC 0x00000001
1.396 -#define SQLITE_IOCAP_ATOMIC512 0x00000002
1.397 -#define SQLITE_IOCAP_ATOMIC1K 0x00000004
1.398 -#define SQLITE_IOCAP_ATOMIC2K 0x00000008
1.399 -#define SQLITE_IOCAP_ATOMIC4K 0x00000010
1.400 -#define SQLITE_IOCAP_ATOMIC8K 0x00000020
1.401 -#define SQLITE_IOCAP_ATOMIC16K 0x00000040
1.402 -#define SQLITE_IOCAP_ATOMIC32K 0x00000080
1.403 -#define SQLITE_IOCAP_ATOMIC64K 0x00000100
1.404 -#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
1.405 -#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
1.406 -
1.407 -/*
1.408 -** CAPI3REF: File Locking Levels
1.409 -**
1.410 -** SQLite uses one of the following integer values as the second
1.411 -** argument to calls it makes to the xLock() and xUnlock() methods
1.412 -** of an [sqlite3_io_methods] object.
1.413 -*/
1.414 -#define SQLITE_LOCK_NONE 0
1.415 -#define SQLITE_LOCK_SHARED 1
1.416 -#define SQLITE_LOCK_RESERVED 2
1.417 -#define SQLITE_LOCK_PENDING 3
1.418 -#define SQLITE_LOCK_EXCLUSIVE 4
1.419 -
1.420 -/*
1.421 -** CAPI3REF: Synchronization Type Flags
1.422 -**
1.423 -** When SQLite invokes the xSync() method of an [sqlite3_io_methods]
1.424 -** object it uses a combination of the following integer values as
1.425 -** the second argument.
1.426 -**
1.427 -** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
1.428 -** sync operation only needs to flush data to mass storage. Inode
1.429 -** information need not be flushed. The SQLITE_SYNC_NORMAL means
1.430 -** to use normal fsync() semantics. The SQLITE_SYNC_FULL flag means
1.431 -** to use Mac OS-X style fullsync instead of fsync().
1.432 -*/
1.433 -#define SQLITE_SYNC_NORMAL 0x00002
1.434 -#define SQLITE_SYNC_FULL 0x00003
1.435 -#define SQLITE_SYNC_DATAONLY 0x00010
1.436 -
1.437 -
1.438 -/*
1.439 -** CAPI3REF: OS Interface Open File Handle
1.440 -**
1.441 -** An [sqlite3_file] object represents an open file in the OS
1.442 -** interface layer. Individual OS interface implementations will
1.443 -** want to subclass this object by appending additional fields
1.444 -** for their own use. The pMethods entry is a pointer to an
1.445 -** [sqlite3_io_methods] object that defines methods for performing
1.446 -** I/O operations on the open file.
1.447 -*/
1.448 -typedef struct sqlite3_file sqlite3_file;
1.449 -struct sqlite3_file {
1.450 - const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
1.451 -};
1.452 -
1.453 -/*
1.454 -** CAPI3REF: OS Interface File Virtual Methods Object
1.455 -**
1.456 -** Every file opened by the [sqlite3_vfs] xOpen method contains a pointer to
1.457 -** an instance of the this object. This object defines the
1.458 -** methods used to perform various operations against the open file.
1.459 -**
1.460 -** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
1.461 -** [SQLITE_SYNC_FULL]. The first choice is the normal fsync().
1.462 -* The second choice is an
1.463 -** OS-X style fullsync. The SQLITE_SYNC_DATA flag may be ORed in to
1.464 -** indicate that only the data of the file and not its inode needs to be
1.465 -** synced.
1.466 -**
1.467 -** The integer values to xLock() and xUnlock() are one of
1.468 -** <ul>
1.469 -** <li> [SQLITE_LOCK_NONE],
1.470 -** <li> [SQLITE_LOCK_SHARED],
1.471 -** <li> [SQLITE_LOCK_RESERVED],
1.472 -** <li> [SQLITE_LOCK_PENDING], or
1.473 -** <li> [SQLITE_LOCK_EXCLUSIVE].
1.474 -** </ul>
1.475 -** xLock() increases the lock. xUnlock() decreases the lock.
1.476 -** The xCheckReservedLock() method looks
1.477 -** to see if any database connection, either in this
1.478 -** process or in some other process, is holding an RESERVED,
1.479 -** PENDING, or EXCLUSIVE lock on the file. It returns true
1.480 -** if such a lock exists and false if not.
1.481 -**
1.482 -** The xFileControl() method is a generic interface that allows custom
1.483 -** VFS implementations to directly control an open file using the
1.484 -** [sqlite3_file_control()] interface. The second "op" argument
1.485 -** is an integer opcode. The third
1.486 -** argument is a generic pointer which is intended to be a pointer
1.487 -** to a structure that may contain arguments or space in which to
1.488 -** write return values. Potential uses for xFileControl() might be
1.489 -** functions to enable blocking locks with timeouts, to change the
1.490 -** locking strategy (for example to use dot-file locks), to inquire
1.491 -** about the status of a lock, or to break stale locks. The SQLite
1.492 -** core reserves opcodes less than 100 for its own use.
1.493 -** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.
1.494 -** Applications that define a custom xFileControl method should use opcodes
1.495 -** greater than 100 to avoid conflicts.
1.496 -**
1.497 -** The xSectorSize() method returns the sector size of the
1.498 -** device that underlies the file. The sector size is the
1.499 -** minimum write that can be performed without disturbing
1.500 -** other bytes in the file. The xDeviceCharacteristics()
1.501 -** method returns a bit vector describing behaviors of the
1.502 -** underlying device:
1.503 -**
1.504 -** <ul>
1.505 -** <li> [SQLITE_IOCAP_ATOMIC]
1.506 -** <li> [SQLITE_IOCAP_ATOMIC512]
1.507 -** <li> [SQLITE_IOCAP_ATOMIC1K]
1.508 -** <li> [SQLITE_IOCAP_ATOMIC2K]
1.509 -** <li> [SQLITE_IOCAP_ATOMIC4K]
1.510 -** <li> [SQLITE_IOCAP_ATOMIC8K]
1.511 -** <li> [SQLITE_IOCAP_ATOMIC16K]
1.512 -** <li> [SQLITE_IOCAP_ATOMIC32K]
1.513 -** <li> [SQLITE_IOCAP_ATOMIC64K]
1.514 -** <li> [SQLITE_IOCAP_SAFE_APPEND]
1.515 -** <li> [SQLITE_IOCAP_SEQUENTIAL]
1.516 -** </ul>
1.517 -**
1.518 -** The SQLITE_IOCAP_ATOMIC property means that all writes of
1.519 -** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
1.520 -** mean that writes of blocks that are nnn bytes in size and
1.521 -** are aligned to an address which is an integer multiple of
1.522 -** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
1.523 -** that when data is appended to a file, the data is appended
1.524 -** first then the size of the file is extended, never the other
1.525 -** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
1.526 -** information is written to disk in the same order as calls
1.527 -** to xWrite().
1.528 -*/
1.529 -typedef struct sqlite3_io_methods sqlite3_io_methods;
1.530 -struct sqlite3_io_methods {
1.531 - int iVersion;
1.532 - int (*xClose)(sqlite3_file*);
1.533 - int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
1.534 - int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
1.535 - int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
1.536 - int (*xSync)(sqlite3_file*, int flags);
1.537 - int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
1.538 - int (*xLock)(sqlite3_file*, int);
1.539 - int (*xUnlock)(sqlite3_file*, int);
1.540 - int (*xCheckReservedLock)(sqlite3_file*);
1.541 - int (*xFileControl)(sqlite3_file*, int op, void *pArg);
1.542 - int (*xSectorSize)(sqlite3_file*);
1.543 - int (*xDeviceCharacteristics)(sqlite3_file*);
1.544 - /* Additional methods may be added in future releases */
1.545 -};
1.546 -
1.547 -/*
1.548 -** CAPI3REF: Standard File Control Opcodes
1.549 -**
1.550 -** These integer constants are opcodes for the xFileControl method
1.551 -** of the [sqlite3_io_methods] object and to the [sqlite3_file_control()]
1.552 -** interface.
1.553 -**
1.554 -** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
1.555 -** opcode cases the xFileControl method to write the current state of
1.556 -** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
1.557 -** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
1.558 -** into an integer that the pArg argument points to. This capability
1.559 -** is used during testing and only needs to be supported when SQLITE_TEST
1.560 -** is defined.
1.561 -*/
1.562 -#define SQLITE_FCNTL_LOCKSTATE 1
1.563 -
1.564 -/*
1.565 -** CAPI3REF: Mutex Handle
1.566 -**
1.567 -** The mutex module within SQLite defines [sqlite3_mutex] to be an
1.568 -** abstract type for a mutex object. The SQLite core never looks
1.569 -** at the internal representation of an [sqlite3_mutex]. It only
1.570 -** deals with pointers to the [sqlite3_mutex] object.
1.571 -**
1.572 -** Mutexes are created using [sqlite3_mutex_alloc()].
1.573 -*/
1.574 -typedef struct sqlite3_mutex sqlite3_mutex;
1.575 -
1.576 -/*
1.577 -** CAPI3REF: OS Interface Object
1.578 -**
1.579 -** An instance of this object defines the interface between the
1.580 -** SQLite core and the underlying operating system. The "vfs"
1.581 -** in the name of the object stands for "virtual file system".
1.582 -**
1.583 -** The iVersion field is initially 1 but may be larger for future
1.584 -** versions of SQLite. Additional fields may be appended to this
1.585 -** object when the iVersion value is increased.
1.586 -**
1.587 -** The szOsFile field is the size of the subclassed [sqlite3_file]
1.588 -** structure used by this VFS. mxPathname is the maximum length of
1.589 -** a pathname in this VFS.
1.590 -**
1.591 -** Registered vfs modules are kept on a linked list formed by
1.592 -** the pNext pointer. The [sqlite3_vfs_register()]
1.593 -** and [sqlite3_vfs_unregister()] interfaces manage this list
1.594 -** in a thread-safe way. The [sqlite3_vfs_find()] interface
1.595 -** searches the list.
1.596 -**
1.597 -** The pNext field is the only fields in the sqlite3_vfs
1.598 -** structure that SQLite will ever modify. SQLite will only access
1.599 -** or modify this field while holding a particular static mutex.
1.600 -** The application should never modify anything within the sqlite3_vfs
1.601 -** object once the object has been registered.
1.602 -**
1.603 -** The zName field holds the name of the VFS module. The name must
1.604 -** be unique across all VFS modules.
1.605 -**
1.606 -** SQLite will guarantee that the zFilename string passed to
1.607 -** xOpen() is a full pathname as generated by xFullPathname() and
1.608 -** that the string will be valid and unchanged until xClose() is
1.609 -** called. So the [sqlite3_file] can store a pointer to the
1.610 -** filename if it needs to remember the filename for some reason.
1.611 -**
1.612 -** The flags argument to xOpen() is a copy of the flags argument
1.613 -** to [sqlite3_open_v2()]. If [sqlite3_open()] or [sqlite3_open16()]
1.614 -** is used, then flags is [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE].
1.615 -** If xOpen() opens a file read-only then it sets *pOutFlags to
1.616 -** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be
1.617 -** set.
1.618 -**
1.619 -** SQLite will also add one of the following flags to the xOpen()
1.620 -** call, depending on the object being opened:
1.621 -**
1.622 -** <ul>
1.623 -** <li> [SQLITE_OPEN_MAIN_DB]
1.624 -** <li> [SQLITE_OPEN_MAIN_JOURNAL]
1.625 -** <li> [SQLITE_OPEN_TEMP_DB]
1.626 -** <li> [SQLITE_OPEN_TEMP_JOURNAL]
1.627 -** <li> [SQLITE_OPEN_TRANSIENT_DB]
1.628 -** <li> [SQLITE_OPEN_SUBJOURNAL]
1.629 -** <li> [SQLITE_OPEN_MASTER_JOURNAL]
1.630 -** </ul>
1.631 -**
1.632 -** The file I/O implementation can use the object type flags to
1.633 -** changes the way it deals with files. For example, an application
1.634 -** that does not care about crash recovery or rollback, might make
1.635 -** the open of a journal file a no-op. Writes to this journal are
1.636 -** also a no-op. Any attempt to read the journal return SQLITE_IOERR.
1.637 -** Or the implementation might recognize the a database file will
1.638 -** be doing page-aligned sector reads and writes in a random order
1.639 -** and set up its I/O subsystem accordingly.
1.640 -**
1.641 -** SQLite might also add one of the following flags to the xOpen
1.642 -** method:
1.643 -**
1.644 -** <ul>
1.645 -** <li> [SQLITE_OPEN_DELETEONCLOSE]
1.646 -** <li> [SQLITE_OPEN_EXCLUSIVE]
1.647 -** </ul>
1.648 -**
1.649 -** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be
1.650 -** deleted when it is closed. This will always be set for TEMP
1.651 -** databases and journals and for subjournals. The
1.652 -** [SQLITE_OPEN_EXCLUSIVE] flag means the file should be opened
1.653 -** for exclusive access. This flag is set for all files except
1.654 -** for the main database file.
1.655 -**
1.656 -** Space to hold the [sqlite3_file] structure passed as the third
1.657 -** argument to xOpen is allocated by caller (the SQLite core).
1.658 -** szOsFile bytes are allocated for this object. The xOpen method
1.659 -** fills in the allocated space.
1.660 -**
1.661 -** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
1.662 -** to test for the existance of a file,
1.663 -** or [SQLITE_ACCESS_READWRITE] to test to see
1.664 -** if a file is readable and writable, or [SQLITE_ACCESS_READ]
1.665 -** to test to see if a file is at least readable. The file can be a
1.666 -** directory.
1.667 -**
1.668 -** SQLite will always allocate at least mxPathname+1 byte for
1.669 -** the output buffers for xGetTempname and xFullPathname. The exact
1.670 -** size of the output buffer is also passed as a parameter to both
1.671 -** methods. If the output buffer is not large enough, SQLITE_CANTOPEN
1.672 -** should be returned. As this is handled as a fatal error by SQLite,
1.673 -** vfs implementations should endevour to prevent this by setting
1.674 -** mxPathname to a sufficiently large value.
1.675 -**
1.676 -** The xRandomness(), xSleep(), and xCurrentTime() interfaces
1.677 -** are not strictly a part of the filesystem, but they are
1.678 -** included in the VFS structure for completeness.
1.679 -** The xRandomness() function attempts to return nBytes bytes
1.680 -** of good-quality randomness into zOut. The return value is
1.681 -** the actual number of bytes of randomness obtained. The
1.682 -** xSleep() method cause the calling thread to sleep for at
1.683 -** least the number of microseconds given. The xCurrentTime()
1.684 -** method returns a Julian Day Number for the current date and
1.685 -** time.
1.686 -*/
1.687 -typedef struct sqlite3_vfs sqlite3_vfs;
1.688 -struct sqlite3_vfs {
1.689 - int iVersion; /* Structure version number */
1.690 - int szOsFile; /* Size of subclassed sqlite3_file */
1.691 - int mxPathname; /* Maximum file pathname length */
1.692 - sqlite3_vfs *pNext; /* Next registered VFS */
1.693 - const char *zName; /* Name of this virtual file system */
1.694 - void *pAppData; /* Pointer to application-specific data */
1.695 - int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
1.696 - int flags, int *pOutFlags);
1.697 - int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1.698 - int (*xAccess)(sqlite3_vfs*, const char *zName, int flags);
1.699 - int (*xGetTempname)(sqlite3_vfs*, int nOut, char *zOut);
1.700 - int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
1.701 - void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
1.702 - void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
1.703 - void *(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol);
1.704 - void (*xDlClose)(sqlite3_vfs*, void*);
1.705 - int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
1.706 - int (*xSleep)(sqlite3_vfs*, int microseconds);
1.707 - int (*xCurrentTime)(sqlite3_vfs*, double*);
1.708 - /* New fields may be appended in figure versions. The iVersion
1.709 - ** value will increment whenever this happens. */
1.710 -};
1.711 -
1.712 -/*
1.713 -** CAPI3REF: Flags for the xAccess VFS method
1.714 -**
1.715 -** These integer constants can be used as the third parameter to
1.716 -** the xAccess method of an [sqlite3_vfs] object. They determine
1.717 -** the kind of what kind of permissions the xAccess method is
1.718 -** looking for. With SQLITE_ACCESS_EXISTS, the xAccess method
1.719 -** simply checks to see if the file exists. With SQLITE_ACCESS_READWRITE,
1.720 -** the xAccess method checks to see if the file is both readable
1.721 -** and writable. With SQLITE_ACCESS_READ the xAccess method
1.722 -** checks to see if the file is readable.
1.723 -*/
1.724 -#define SQLITE_ACCESS_EXISTS 0
1.725 -#define SQLITE_ACCESS_READWRITE 1
1.726 -#define SQLITE_ACCESS_READ 2
1.727 -
1.728 -/*
1.729 -** CAPI3REF: Enable Or Disable Extended Result Codes
1.730 -**
1.731 -** This routine enables or disables the
1.732 -** [SQLITE_IOERR_READ | extended result codes] feature.
1.733 -** By default, SQLite API routines return one of only 26 integer
1.734 -** [SQLITE_OK | result codes]. When extended result codes
1.735 -** are enabled by this routine, the repetoire of result codes can be
1.736 -** much larger and can (hopefully) provide more detailed information
1.737 -** about the cause of an error.
1.738 -**
1.739 -** The second argument is a boolean value that turns extended result
1.740 -** codes on and off. Extended result codes are off by default for
1.741 -** backwards compatibility with older versions of SQLite.
1.742 -*/
1.743 -int sqlite3_extended_result_codes(sqlite3*, int onoff);
1.744 -
1.745 -/*
1.746 -** CAPI3REF: Last Insert Rowid
1.747 -**
1.748 -** Each entry in an SQLite table has a unique 64-bit signed integer key
1.749 -** called the "rowid". The rowid is always available as an undeclared
1.750 -** column named ROWID, OID, or _ROWID_. If the table has a column of
1.751 -** type INTEGER PRIMARY KEY then that column is another an alias for the
1.752 -** rowid.
1.753 -**
1.754 -** This routine returns the rowid of the most recent INSERT into
1.755 -** the database from the database connection given in the first
1.756 -** argument. If no inserts have ever occurred on this database
1.757 -** connection, zero is returned.
1.758 -**
1.759 -** If an INSERT occurs within a trigger, then the rowid of the
1.760 -** inserted row is returned by this routine as long as the trigger
1.761 -** is running. But once the trigger terminates, the value returned
1.762 -** by this routine reverts to the last value inserted before the
1.763 -** trigger fired.
1.764 -**
1.765 -** If another thread does a new insert on the same database connection
1.766 -** while this routine is running and thus changes the last insert rowid,
1.767 -** then the return value of this routine is undefined.
1.768 -*/
1.769 -sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1.770 -
1.771 -/*
1.772 -** CAPI3REF: Count The Number Of Rows Modified
1.773 -**
1.774 -** This function returns the number of database rows that were changed
1.775 -** (or inserted or deleted) by the most recent SQL statement. Only
1.776 -** changes that are directly specified by the INSERT, UPDATE, or
1.777 -** DELETE statement are counted. Auxiliary changes caused by
1.778 -** triggers are not counted. Use the [sqlite3_total_changes()] function
1.779 -** to find the total number of changes including changes caused by triggers.
1.780 -**
1.781 -** Within the body of a trigger, the sqlite3_changes() interface can be
1.782 -** called to find the number of
1.783 -** changes in the most recently completed INSERT, UPDATE, or DELETE
1.784 -** statement within the body of the trigger.
1.785 -**
1.786 -** All changes are counted, even if they were later undone by a
1.787 -** ROLLBACK or ABORT. Except, changes associated with creating and
1.788 -** dropping tables are not counted.
1.789 -**
1.790 -** If a callback invokes [sqlite3_exec()] or [sqlite3_step()] recursively,
1.791 -** then the changes in the inner, recursive call are counted together
1.792 -** with the changes in the outer call.
1.793 -**
1.794 -** SQLite implements the command "DELETE FROM table" without a WHERE clause
1.795 -** by dropping and recreating the table. (This is much faster than going
1.796 -** through and deleting individual elements from the table.) Because of
1.797 -** this optimization, the change count for "DELETE FROM table" will be
1.798 -** zero regardless of the number of elements that were originally in the
1.799 -** table. To get an accurate count of the number of rows deleted, use
1.800 -** "DELETE FROM table WHERE 1" instead.
1.801 -**
1.802 -** If another thread makes changes on the same database connection
1.803 -** while this routine is running then the return value of this routine
1.804 -** is undefined.
1.805 -*/
1.806 -int sqlite3_changes(sqlite3*);
1.807 -
1.808 -/*
1.809 -** CAPI3REF: Total Number Of Rows Modified
1.810 -***
1.811 -** This function returns the number of database rows that have been
1.812 -** modified by INSERT, UPDATE or DELETE statements since the database handle
1.813 -** was opened. This includes UPDATE, INSERT and DELETE statements executed
1.814 -** as part of trigger programs. All changes are counted as soon as the
1.815 -** statement that makes them is completed (when the statement handle is
1.816 -** passed to [sqlite3_reset()] or [sqlite3_finalize()]).
1.817 -**
1.818 -** See also the [sqlite3_change()] interface.
1.819 -**
1.820 -** SQLite implements the command "DELETE FROM table" without a WHERE clause
1.821 -** by dropping and recreating the table. (This is much faster than going
1.822 -** through and deleting individual elements form the table.) Because of
1.823 -** this optimization, the change count for "DELETE FROM table" will be
1.824 -** zero regardless of the number of elements that were originally in the
1.825 -** table. To get an accurate count of the number of rows deleted, use
1.826 -** "DELETE FROM table WHERE 1" instead.
1.827 -**
1.828 -** If another thread makes changes on the same database connection
1.829 -** while this routine is running then the return value of this routine
1.830 -** is undefined.
1.831 -*/
1.832 -int sqlite3_total_changes(sqlite3*);
1.833 -
1.834 -/*
1.835 -** CAPI3REF: Interrupt A Long-Running Query
1.836 -**
1.837 -** This function causes any pending database operation to abort and
1.838 -** return at its earliest opportunity. This routine is typically
1.839 -** called in response to a user action such as pressing "Cancel"
1.840 -** or Ctrl-C where the user wants a long query operation to halt
1.841 -** immediately.
1.842 -**
1.843 -** It is safe to call this routine from a thread different from the
1.844 -** thread that is currently running the database operation. But it
1.845 -** is not safe to call this routine with a database connection that
1.846 -** is closed or might close before sqlite3_interrupt() returns.
1.847 -**
1.848 -** The SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1.849 -** If an interrupted operation was an update that is inside an
1.850 -** explicit transaction, then the entire transaction will be rolled
1.851 -** back automatically.
1.852 -*/
1.853 -void sqlite3_interrupt(sqlite3*);
1.854 -
1.855 -/*
1.856 -** CAPI3REF: Determine If An SQL Statement Is Complete
1.857 -**
1.858 -** These functions return true if the given input string comprises
1.859 -** one or more complete SQL statements. For the sqlite3_complete() call,
1.860 -** the parameter must be a nul-terminated UTF-8 string. For
1.861 -** sqlite3_complete16(), a nul-terminated machine byte order UTF-16 string
1.862 -** is required.
1.863 -**
1.864 -** These routines are useful for command-line input to determine if the
1.865 -** currently entered text forms one or more complete SQL statements or
1.866 -** if additional input is needed before sending the statements into
1.867 -** SQLite for parsing. The algorithm is simple. If the
1.868 -** last token other than spaces and comments is a semicolon, then return
1.869 -** true. Actually, the algorithm is a little more complicated than that
1.870 -** in order to deal with triggers, but the basic idea is the same: the
1.871 -** statement is not complete unless it ends in a semicolon.
1.872 -*/
1.873 -int sqlite3_complete(const char *sql);
1.874 -int sqlite3_complete16(const void *sql);
1.875 -
1.876 -/*
1.877 -** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
1.878 -**
1.879 -** This routine identifies a callback function that might be invoked
1.880 -** whenever an attempt is made to open a database table
1.881 -** that another thread or process has locked.
1.882 -** If the busy callback is NULL, then [SQLITE_BUSY]
1.883 -** (or sometimes [SQLITE_IOERR_BLOCKED])
1.884 -** is returned immediately upon encountering the lock.
1.885 -** If the busy callback is not NULL, then the
1.886 -** callback will be invoked with two arguments. The
1.887 -** first argument to the handler is a copy of the void* pointer which
1.888 -** is the third argument to this routine. The second argument to
1.889 -** the handler is the number of times that the busy handler has
1.890 -** been invoked for this locking event. If the
1.891 -** busy callback returns 0, then no additional attempts are made to
1.892 -** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
1.893 -** If the callback returns non-zero, then another attempt is made to open the
1.894 -** database for reading and the cycle repeats.
1.895 -**
1.896 -** The presence of a busy handler does not guarantee that
1.897 -** it will be invoked when there is lock contention.
1.898 -** If SQLite determines that invoking the busy handler could result in
1.899 -** a deadlock, it will return [SQLITE_BUSY] instead.
1.900 -** Consider a scenario where one process is holding a read lock that
1.901 -** it is trying to promote to a reserved lock and
1.902 -** a second process is holding a reserved lock that it is trying
1.903 -** to promote to an exclusive lock. The first process cannot proceed
1.904 -** because it is blocked by the second and the second process cannot
1.905 -** proceed because it is blocked by the first. If both processes
1.906 -** invoke the busy handlers, neither will make any progress. Therefore,
1.907 -** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
1.908 -** will induce the first process to release its read lock and allow
1.909 -** the second process to proceed.
1.910 -**
1.911 -** The default busy callback is NULL.
1.912 -**
1.913 -** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] when
1.914 -** SQLite is in the middle of a large transaction where all the
1.915 -** changes will not fit into the in-memory cache. SQLite will
1.916 -** already hold a RESERVED lock on the database file, but it needs
1.917 -** to promote this lock to EXCLUSIVE so that it can spill cache
1.918 -** pages into the database file without harm to concurrent
1.919 -** readers. If it is unable to promote the lock, then the in-memory
1.920 -** cache will be left in an inconsistent state and so the error
1.921 -** code is promoted from the relatively benign [SQLITE_BUSY] to
1.922 -** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion
1.923 -** forces an automatic rollback of the changes. See the
1.924 -** <a href="http://www.sqlite.org/cvstrac/wiki?p=CorruptionFollowingBusyError">
1.925 -** CorruptionFollowingBusyError</a> wiki page for a discussion of why
1.926 -** this is important.
1.927 -**
1.928 -** Sqlite is re-entrant, so the busy handler may start a new query.
1.929 -** (It is not clear why anyone would every want to do this, but it
1.930 -** is allowed, in theory.) But the busy handler may not close the
1.931 -** database. Closing the database from a busy handler will delete
1.932 -** data structures out from under the executing query and will
1.933 -** probably result in a segmentation fault or other runtime error.
1.934 -**
1.935 -** There can only be a single busy handler defined for each database
1.936 -** connection. Setting a new busy handler clears any previous one.
1.937 -** Note that calling [sqlite3_busy_timeout()] will also set or clear
1.938 -** the busy handler.
1.939 -**
1.940 -** When operating in [sqlite3_enable_shared_cache | shared cache mode],
1.941 -** only a single busy handler can be defined for each database file.
1.942 -** So if two database connections share a single cache, then changing
1.943 -** the busy handler on one connection will also change the busy
1.944 -** handler in the other connection. The busy handler is invoked
1.945 -** in the thread that was running when the SQLITE_BUSY was hit.
1.946 -*/
1.947 -int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
1.948 -
1.949 -/*
1.950 -** CAPI3REF: Set A Busy Timeout
1.951 -**
1.952 -** This routine sets a busy handler that sleeps for a while when a
1.953 -** table is locked. The handler will sleep multiple times until
1.954 -** at least "ms" milliseconds of sleeping have been done. After
1.955 -** "ms" milliseconds of sleeping, the handler returns 0 which
1.956 -** causes [sqlite3_step()] to return [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
1.957 -**
1.958 -** Calling this routine with an argument less than or equal to zero
1.959 -** turns off all busy handlers.
1.960 -**
1.961 -** There can only be a single busy handler for a particular database
1.962 -** connection. If another busy handler was defined
1.963 -** (using [sqlite3_busy_handler()]) prior to calling
1.964 -** this routine, that other busy handler is cleared.
1.965 -*/
1.966 -int sqlite3_busy_timeout(sqlite3*, int ms);
1.967 -
1.968 -/*
1.969 -** CAPI3REF: Convenience Routines For Running Queries
1.970 -**
1.971 -** This next routine is a convenience wrapper around [sqlite3_exec()].
1.972 -** Instead of invoking a user-supplied callback for each row of the
1.973 -** result, this routine remembers each row of the result in memory
1.974 -** obtained from [sqlite3_malloc()], then returns all of the result after the
1.975 -** query has finished.
1.976 -**
1.977 -** As an example, suppose the query result where this table:
1.978 -**
1.979 -** <blockquote><pre>
1.980 -** Name | Age
1.981 -** -----------------------
1.982 -** Alice | 43
1.983 -** Bob | 28
1.984 -** Cindy | 21
1.985 -** </pre></blockquote>
1.986 -**
1.987 -** If the 3rd argument were &azResult then after the function returns
1.988 -** azResult will contain the following data:
1.989 -**
1.990 -** <blockquote><pre>
1.991 -** azResult[0] = "Name";
1.992 -** azResult[1] = "Age";
1.993 -** azResult[2] = "Alice";
1.994 -** azResult[3] = "43";
1.995 -** azResult[4] = "Bob";
1.996 -** azResult[5] = "28";
1.997 -** azResult[6] = "Cindy";
1.998 -** azResult[7] = "21";
1.999 -** </pre></blockquote>
1.1000 -**
1.1001 -** Notice that there is an extra row of data containing the column
1.1002 -** headers. But the *nrow return value is still 3. *ncolumn is
1.1003 -** set to 2. In general, the number of values inserted into azResult
1.1004 -** will be ((*nrow) + 1)*(*ncolumn).
1.1005 -**
1.1006 -** After the calling function has finished using the result, it should
1.1007 -** pass the result data pointer to sqlite3_free_table() in order to
1.1008 -** release the memory that was malloc-ed. Because of the way the
1.1009 -** [sqlite3_malloc()] happens, the calling function must not try to call
1.1010 -** [sqlite3_free()] directly. Only [sqlite3_free_table()] is able to release
1.1011 -** the memory properly and safely.
1.1012 -**
1.1013 -** The return value of this routine is the same as from [sqlite3_exec()].
1.1014 -*/
1.1015 -int sqlite3_get_table(
1.1016 - sqlite3*, /* An open database */
1.1017 - const char *sql, /* SQL to be executed */
1.1018 - char ***resultp, /* Result written to a char *[] that this points to */
1.1019 - int *nrow, /* Number of result rows written here */
1.1020 - int *ncolumn, /* Number of result columns written here */
1.1021 - char **errmsg /* Error msg written here */
1.1022 -);
1.1023 -void sqlite3_free_table(char **result);
1.1024 -
1.1025 -/*
1.1026 -** CAPI3REF: Formatted String Printing Functions
1.1027 -**
1.1028 -** These routines are workalikes of the "printf()" family of functions
1.1029 -** from the standard C library.
1.1030 -**
1.1031 -** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
1.1032 -** results into memory obtained from [sqlite3_malloc()].
1.1033 -** The strings returned by these two routines should be
1.1034 -** released by [sqlite3_free()]. Both routines return a
1.1035 -** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
1.1036 -** memory to hold the resulting string.
1.1037 -**
1.1038 -** In sqlite3_snprintf() routine is similar to "snprintf()" from
1.1039 -** the standard C library. The result is written into the
1.1040 -** buffer supplied as the second parameter whose size is given by
1.1041 -** the first parameter. Note that the order of the
1.1042 -** first two parameters is reversed from snprintf(). This is an
1.1043 -** historical accident that cannot be fixed without breaking
1.1044 -** backwards compatibility. Note also that sqlite3_snprintf()
1.1045 -** returns a pointer to its buffer instead of the number of
1.1046 -** characters actually written into the buffer. We admit that
1.1047 -** the number of characters written would be a more useful return
1.1048 -** value but we cannot change the implementation of sqlite3_snprintf()
1.1049 -** now without breaking compatibility.
1.1050 -**
1.1051 -** As long as the buffer size is greater than zero, sqlite3_snprintf()
1.1052 -** guarantees that the buffer is always zero-terminated. The first
1.1053 -** parameter "n" is the total size of the buffer, including space for
1.1054 -** the zero terminator. So the longest string that can be completely
1.1055 -** written will be n-1 characters.
1.1056 -**
1.1057 -** These routines all implement some additional formatting
1.1058 -** options that are useful for constructing SQL statements.
1.1059 -** All of the usual printf formatting options apply. In addition, there
1.1060 -** is are "%q", "%Q", and "%z" options.
1.1061 -**
1.1062 -** The %q option works like %s in that it substitutes a null-terminated
1.1063 -** string from the argument list. But %q also doubles every '\'' character.
1.1064 -** %q is designed for use inside a string literal. By doubling each '\''
1.1065 -** character it escapes that character and allows it to be inserted into
1.1066 -** the string.
1.1067 -**
1.1068 -** For example, so some string variable contains text as follows:
1.1069 -**
1.1070 -** <blockquote><pre>
1.1071 -** char *zText = "It's a happy day!";
1.1072 -** </pre></blockquote>
1.1073 -**
1.1074 -** One can use this text in an SQL statement as follows:
1.1075 -**
1.1076 -** <blockquote><pre>
1.1077 -** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
1.1078 -** sqlite3_exec(db, zSQL, 0, 0, 0);
1.1079 -** sqlite3_free(zSQL);
1.1080 -** </pre></blockquote>
1.1081 -**
1.1082 -** Because the %q format string is used, the '\'' character in zText
1.1083 -** is escaped and the SQL generated is as follows:
1.1084 -**
1.1085 -** <blockquote><pre>
1.1086 -** INSERT INTO table1 VALUES('It''s a happy day!')
1.1087 -** </pre></blockquote>
1.1088 -**
1.1089 -** This is correct. Had we used %s instead of %q, the generated SQL
1.1090 -** would have looked like this:
1.1091 -**
1.1092 -** <blockquote><pre>
1.1093 -** INSERT INTO table1 VALUES('It's a happy day!');
1.1094 -** </pre></blockquote>
1.1095 -**
1.1096 -** This second example is an SQL syntax error. As a general rule you
1.1097 -** should always use %q instead of %s when inserting text into a string
1.1098 -** literal.
1.1099 -**
1.1100 -** The %Q option works like %q except it also adds single quotes around
1.1101 -** the outside of the total string. Or if the parameter in the argument
1.1102 -** list is a NULL pointer, %Q substitutes the text "NULL" (without single
1.1103 -** quotes) in place of the %Q option. So, for example, one could say:
1.1104 -**
1.1105 -** <blockquote><pre>
1.1106 -** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
1.1107 -** sqlite3_exec(db, zSQL, 0, 0, 0);
1.1108 -** sqlite3_free(zSQL);
1.1109 -** </pre></blockquote>
1.1110 -**
1.1111 -** The code above will render a correct SQL statement in the zSQL
1.1112 -** variable even if the zText variable is a NULL pointer.
1.1113 -**
1.1114 -** The "%z" formatting option works exactly like "%s" with the
1.1115 -** addition that after the string has been read and copied into
1.1116 -** the result, [sqlite3_free()] is called on the input string.
1.1117 -*/
1.1118 -char *sqlite3_mprintf(const char*,...);
1.1119 -char *sqlite3_vmprintf(const char*, va_list);
1.1120 -char *sqlite3_snprintf(int,char*,const char*, ...);
1.1121 -
1.1122 -/*
1.1123 -** CAPI3REF: Memory Allocation Subsystem
1.1124 -**
1.1125 -** The SQLite core uses these three routines for all of its own
1.1126 -** internal memory allocation needs. (See the exception below.)
1.1127 -** The default implementation
1.1128 -** of the memory allocation subsystem uses the malloc(), realloc()
1.1129 -** and free() provided by the standard C library. However, if
1.1130 -** SQLite is compiled with the following C preprocessor macro
1.1131 -**
1.1132 -** <blockquote> SQLITE_OMIT_MEMORY_ALLOCATION </blockquote>
1.1133 -**
1.1134 -** then no implementation is provided for these routines by
1.1135 -** SQLite. The application that links against SQLite is
1.1136 -** expected to provide its own implementation. If the application
1.1137 -** does provide its own implementation for these routines, then
1.1138 -** it must also provide an implementations for
1.1139 -** [sqlite3_memory_alarm()], [sqlite3_memory_used()], and
1.1140 -** [sqlite3_memory_highwater()]. The alternative implementations
1.1141 -** for these last three routines need not actually work, but
1.1142 -** stub functions at least are needed to statisfy the linker.
1.1143 -** SQLite never calls [sqlite3_memory_highwater()] itself, but
1.1144 -** the symbol is included in a table as part of the
1.1145 -** [sqlite3_load_extension()] interface. The
1.1146 -** [sqlite3_memory_alarm()] and [sqlite3_memory_used()] interfaces
1.1147 -** are called by [sqlite3_soft_heap_limit()] and working implementations
1.1148 -** of both routines must be provided if [sqlite3_soft_heap_limit()]
1.1149 -** is to operate correctly.
1.1150 -**
1.1151 -** <b>Exception:</b> The windows OS interface layer calls
1.1152 -** the system malloc() and free() directly when converting
1.1153 -** filenames between the UTF-8 encoding used by SQLite
1.1154 -** and whatever filename encoding is used by the particular windows
1.1155 -** installation. Memory allocation errors are detected, but
1.1156 -** they are reported back as [SQLITE_CANTOPEN] or
1.1157 -** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
1.1158 -*/
1.1159 -void *sqlite3_malloc(int);
1.1160 -void *sqlite3_realloc(void*, int);
1.1161 -void sqlite3_free(void*);
1.1162 -
1.1163 -/*
1.1164 -** CAPI3REF: Memory Allocator Statistics
1.1165 -**
1.1166 -** In addition to the basic three allocation routines
1.1167 -** [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()],
1.1168 -** the memory allocation subsystem included with the SQLite
1.1169 -** sources provides the interfaces shown below.
1.1170 -**
1.1171 -** The first of these two routines returns the amount of memory
1.1172 -** currently outstanding (malloced but not freed). The second
1.1173 -** returns the largest instantaneous amount of outstanding
1.1174 -** memory. The highwater mark is reset if the argument is
1.1175 -** true.
1.1176 -**
1.1177 -** The implementation of these routines in the SQLite core
1.1178 -** is omitted if the application is compiled with the
1.1179 -** SQLITE_OMIT_MEMORY_ALLOCATION macro defined. In that case,
1.1180 -** the application that links SQLite must provide its own
1.1181 -** alternative implementation. See the documentation on
1.1182 -** [sqlite3_malloc()] for additional information.
1.1183 -*/
1.1184 -sqlite3_int64 sqlite3_memory_used(void);
1.1185 -sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
1.1186 -
1.1187 -/*
1.1188 -** CAPI3REF: Memory Allocation Alarms
1.1189 -**
1.1190 -** The [sqlite3_memory_alarm] routine is used to register
1.1191 -** a callback on memory allocation events.
1.1192 -**
1.1193 -** This routine registers or clears a callbacks that fires when
1.1194 -** the amount of memory allocated exceeds iThreshold. Only
1.1195 -** a single callback can be registered at a time. Each call
1.1196 -** to [sqlite3_memory_alarm()] overwrites the previous callback.
1.1197 -** The callback is disabled by setting xCallback to a NULL
1.1198 -** pointer.
1.1199 -**
1.1200 -** The parameters to the callback are the pArg value, the
1.1201 -** amount of memory currently in use, and the size of the
1.1202 -** allocation that provoked the callback. The callback will
1.1203 -** presumably invoke [sqlite3_free()] to free up memory space.
1.1204 -** The callback may invoke [sqlite3_malloc()] or [sqlite3_realloc()]
1.1205 -** but if it does, no additional callbacks will be invoked by
1.1206 -** the recursive calls.
1.1207 -**
1.1208 -** The [sqlite3_soft_heap_limit()] interface works by registering
1.1209 -** a memory alarm at the soft heap limit and invoking
1.1210 -** [sqlite3_release_memory()] in the alarm callback. Application
1.1211 -** programs should not attempt to use the [sqlite3_memory_alarm()]
1.1212 -** interface because doing so will interfere with the
1.1213 -** [sqlite3_soft_heap_limit()] module. This interface is exposed
1.1214 -** only so that applications can provide their own
1.1215 -** alternative implementation when the SQLite core is
1.1216 -** compiled with SQLITE_OMIT_MEMORY_ALLOCATION.
1.1217 -*/
1.1218 -int sqlite3_memory_alarm(
1.1219 - void(*xCallback)(void *pArg, sqlite3_int64 used, int N),
1.1220 - void *pArg,
1.1221 - sqlite3_int64 iThreshold
1.1222 -);
1.1223 -
1.1224 -
1.1225 -/*
1.1226 -** CAPI3REF: Compile-Time Authorization Callbacks
1.1227 -***
1.1228 -** This routine registers a authorizer callback with the SQLite library.
1.1229 -** The authorizer callback is invoked as SQL statements are being compiled
1.1230 -** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
1.1231 -** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various
1.1232 -** points during the compilation process, as logic is being created
1.1233 -** to perform various actions, the authorizer callback is invoked to
1.1234 -** see if those actions are allowed. The authorizer callback should
1.1235 -** return SQLITE_OK to allow the action, [SQLITE_IGNORE] to disallow the
1.1236 -** specific action but allow the SQL statement to continue to be
1.1237 -** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
1.1238 -** rejected with an error.
1.1239 -**
1.1240 -** Depending on the action, the [SQLITE_IGNORE] and [SQLITE_DENY] return
1.1241 -** codes might mean something different or they might mean the same
1.1242 -** thing. If the action is, for example, to perform a delete opertion,
1.1243 -** then [SQLITE_IGNORE] and [SQLITE_DENY] both cause the statement compilation
1.1244 -** to fail with an error. But if the action is to read a specific column
1.1245 -** from a specific table, then [SQLITE_DENY] will cause the entire
1.1246 -** statement to fail but [SQLITE_IGNORE] will cause a NULL value to be
1.1247 -** read instead of the actual column value.
1.1248 -**
1.1249 -** The first parameter to the authorizer callback is a copy of
1.1250 -** the third parameter to the sqlite3_set_authorizer() interface.
1.1251 -** The second parameter to the callback is an integer
1.1252 -** [SQLITE_COPY | action code] that specifies the particular action
1.1253 -** to be authorized. The available action codes are
1.1254 -** [SQLITE_COPY | documented separately]. The third through sixth
1.1255 -** parameters to the callback are strings that contain additional
1.1256 -** details about the action to be authorized.
1.1257 -**
1.1258 -** An authorizer is used when preparing SQL statements from an untrusted
1.1259 -** source, to ensure that the SQL statements do not try to access data
1.1260 -** that they are not allowed to see, or that they do not try to
1.1261 -** execute malicious statements that damage the database. For
1.1262 -** example, an application may allow a user to enter arbitrary
1.1263 -** SQL queries for evaluation by a database. But the application does
1.1264 -** not want the user to be able to make arbitrary changes to the
1.1265 -** database. An authorizer could then be put in place while the
1.1266 -** user-entered SQL is being prepared that disallows everything
1.1267 -** except SELECT statements.
1.1268 -**
1.1269 -** Only a single authorizer can be in place on a database connection
1.1270 -** at a time. Each call to sqlite3_set_authorizer overrides the
1.1271 -** previous call. A NULL authorizer means that no authorization
1.1272 -** callback is invoked. The default authorizer is NULL.
1.1273 -**
1.1274 -** Note that the authorizer callback is invoked only during
1.1275 -** [sqlite3_prepare()] or its variants. Authorization is not
1.1276 -** performed during statement evaluation in [sqlite3_step()].
1.1277 -*/
1.1278 -int sqlite3_set_authorizer(
1.1279 - sqlite3*,
1.1280 - int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
1.1281 - void *pUserData
1.1282 -);
1.1283 -
1.1284 -/*
1.1285 -** CAPI3REF: Authorizer Return Codes
1.1286 -**
1.1287 -** The [sqlite3_set_authorizer | authorizer callback function] must
1.1288 -** return either [SQLITE_OK] or one of these two constants in order
1.1289 -** to signal SQLite whether or not the action is permitted. See the
1.1290 -** [sqlite3_set_authorizer | authorizer documentation] for additional
1.1291 -** information.
1.1292 -*/
1.1293 -#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
1.1294 -#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
1.1295 -
1.1296 -/*
1.1297 -** CAPI3REF: Authorizer Action Codes
1.1298 -**
1.1299 -** The [sqlite3_set_authorizer()] interface registers a callback function
1.1300 -** that is invoked to authorizer certain SQL statement actions. The
1.1301 -** second parameter to the callback is an integer code that specifies
1.1302 -** what action is being authorized. These are the integer action codes that
1.1303 -** the authorizer callback may be passed.
1.1304 -**
1.1305 -** These action code values signify what kind of operation is to be
1.1306 -** authorized. The 3rd and 4th parameters to the authorization callback
1.1307 -** function will be parameters or NULL depending on which of these
1.1308 -** codes is used as the second parameter. The 5th parameter to the
1.1309 -** authorizer callback is the name of the database ("main", "temp",
1.1310 -** etc.) if applicable. The 6th parameter to the authorizer callback
1.1311 -** is the name of the inner-most trigger or view that is responsible for
1.1312 -** the access attempt or NULL if this access attempt is directly from
1.1313 -** top-level SQL code.
1.1314 -*/
1.1315 -/******************************************* 3rd ************ 4th ***********/
1.1316 -#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
1.1317 -#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
1.1318 -#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
1.1319 -#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */
1.1320 -#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */
1.1321 -#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */
1.1322 -#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */
1.1323 -#define SQLITE_CREATE_VIEW 8 /* View Name NULL */
1.1324 -#define SQLITE_DELETE 9 /* Table Name NULL */
1.1325 -#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */
1.1326 -#define SQLITE_DROP_TABLE 11 /* Table Name NULL */
1.1327 -#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */
1.1328 -#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */
1.1329 -#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */
1.1330 -#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */
1.1331 -#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */
1.1332 -#define SQLITE_DROP_VIEW 17 /* View Name NULL */
1.1333 -#define SQLITE_INSERT 18 /* Table Name NULL */
1.1334 -#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */
1.1335 -#define SQLITE_READ 20 /* Table Name Column Name */
1.1336 -#define SQLITE_SELECT 21 /* NULL NULL */
1.1337 -#define SQLITE_TRANSACTION 22 /* NULL NULL */
1.1338 -#define SQLITE_UPDATE 23 /* Table Name Column Name */
1.1339 -#define SQLITE_ATTACH 24 /* Filename NULL */
1.1340 -#define SQLITE_DETACH 25 /* Database Name NULL */
1.1341 -#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */
1.1342 -#define SQLITE_REINDEX 27 /* Index Name NULL */
1.1343 -#define SQLITE_ANALYZE 28 /* Table Name NULL */
1.1344 -#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
1.1345 -#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
1.1346 -#define SQLITE_FUNCTION 31 /* Function Name NULL */
1.1347 -#define SQLITE_COPY 0 /* No longer used */
1.1348 -
1.1349 -/*
1.1350 -** CAPI3REF: Tracing And Profiling Functions
1.1351 -**
1.1352 -** These routines register callback functions that can be used for
1.1353 -** tracing and profiling the execution of SQL statements.
1.1354 -** The callback function registered by sqlite3_trace() is invoked
1.1355 -** at the first [sqlite3_step()] for the evaluation of an SQL statement.
1.1356 -** The callback function registered by sqlite3_profile() is invoked
1.1357 -** as each SQL statement finishes and includes
1.1358 -** information on how long that statement ran.
1.1359 -**
1.1360 -** The sqlite3_profile() API is currently considered experimental and
1.1361 -** is subject to change.
1.1362 -*/
1.1363 -void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
1.1364 -void *sqlite3_profile(sqlite3*,
1.1365 - void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
1.1366 -
1.1367 -/*
1.1368 -** CAPI3REF: Query Progress Callbacks
1.1369 -**
1.1370 -** This routine configures a callback function - the progress callback - that
1.1371 -** is invoked periodically during long running calls to [sqlite3_exec()],
1.1372 -** [sqlite3_step()] and [sqlite3_get_table()]. An example use for this
1.1373 -** interface is to keep a GUI updated during a large query.
1.1374 -**
1.1375 -** The progress callback is invoked once for every N virtual machine opcodes,
1.1376 -** where N is the second argument to this function. The progress callback
1.1377 -** itself is identified by the third argument to this function. The fourth
1.1378 -** argument to this function is a void pointer passed to the progress callback
1.1379 -** function each time it is invoked.
1.1380 -**
1.1381 -** If a call to [sqlite3_exec()], [sqlite3_step()], or [sqlite3_get_table()]
1.1382 -** results in fewer than N opcodes being executed, then the progress
1.1383 -** callback is never invoked.
1.1384 -**
1.1385 -** Only a single progress callback function may be registered for each
1.1386 -** open database connection. Every call to sqlite3_progress_handler()
1.1387 -** overwrites the results of the previous call.
1.1388 -** To remove the progress callback altogether, pass NULL as the third
1.1389 -** argument to this function.
1.1390 -**
1.1391 -** If the progress callback returns a result other than 0, then the current
1.1392 -** query is immediately terminated and any database changes rolled back.
1.1393 -** The containing [sqlite3_exec()], [sqlite3_step()], or
1.1394 -** [sqlite3_get_table()] call returns SQLITE_INTERRUPT. This feature
1.1395 -** can be used, for example, to implement the "Cancel" button on a
1.1396 -** progress dialog box in a GUI.
1.1397 -*/
1.1398 -void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
1.1399 -
1.1400 -/*
1.1401 -** CAPI3REF: Opening A New Database Connection
1.1402 -**
1.1403 -** Open the sqlite database file "filename". The "filename" is UTF-8
1.1404 -** encoded for [sqlite3_open()] and [sqlite3_open_v2()] and UTF-16 encoded
1.1405 -** in the native byte order for [sqlite3_open16()].
1.1406 -** An [sqlite3*] handle is returned in *ppDb, even
1.1407 -** if an error occurs. If the database is opened (or created) successfully,
1.1408 -** then [SQLITE_OK] is returned. Otherwise an error code is returned. The
1.1409 -** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
1.1410 -** an English language description of the error.
1.1411 -**
1.1412 -** The default encoding for the database will be UTF-8 if
1.1413 -** [sqlite3_open()] or [sqlite3_open_v2()] is called and
1.1414 -** UTF-16 if [sqlite3_open16()] is used.
1.1415 -**
1.1416 -** Whether or not an error occurs when it is opened, resources associated
1.1417 -** with the [sqlite3*] handle should be released by passing it to
1.1418 -** [sqlite3_close()] when it is no longer required.
1.1419 -**
1.1420 -** The [sqlite3_open_v2()] interface works like [sqlite3_open()] except that
1.1421 -** provides two additional parameters for additional control over the
1.1422 -** new database connection. The flags parameter can be one of:
1.1423 -**
1.1424 -** <ol>
1.1425 -** <li> [SQLITE_OPEN_READONLY]
1.1426 -** <li> [SQLITE_OPEN_READWRITE]
1.1427 -** <li> [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
1.1428 -** </ol>
1.1429 -**
1.1430 -** The first value opens the database read-only. If the database does
1.1431 -** not previously exist, an error is returned. The second option opens
1.1432 -** the database for reading and writing if possible, or reading only if
1.1433 -** if the file is write protected. In either case the database must already
1.1434 -** exist or an error is returned. The third option opens the database
1.1435 -** for reading and writing and creates it if it does not already exist.
1.1436 -** The third options is behavior that is always used for [sqlite3_open()]
1.1437 -** and [sqlite3_open16()].
1.1438 -**
1.1439 -** If the filename is ":memory:", then an private
1.1440 -** in-memory database is created for the connection. This in-memory
1.1441 -** database will vanish when the database connection is closed. Future
1.1442 -** version of SQLite might make use of additional special filenames
1.1443 -** that begin with the ":" character. It is recommended that
1.1444 -** when a database filename really does begin with
1.1445 -** ":" that you prefix the filename with a pathname like "./" to
1.1446 -** avoid ambiguity.
1.1447 -**
1.1448 -** If the filename is an empty string, then a private temporary
1.1449 -** on-disk database will be created. This private database will be
1.1450 -** automatically deleted as soon as the database connection is closed.
1.1451 -**
1.1452 -** The fourth parameter to sqlite3_open_v2() is the name of the
1.1453 -** [sqlite3_vfs] object that defines the operating system
1.1454 -** interface that the new database connection should use. If the
1.1455 -** fourth parameter is a NULL pointer then the default [sqlite3_vfs]
1.1456 -** object is used.
1.1457 -**
1.1458 -** <b>Note to windows users:</b> The encoding used for the filename argument
1.1459 -** of [sqlite3_open()] and [sqlite3_open_v2()] must be UTF-8, not whatever
1.1460 -** codepage is currently defined. Filenames containing international
1.1461 -** characters must be converted to UTF-8 prior to passing them into
1.1462 -** [sqlite3_open()] or [sqlite3_open_v2()].
1.1463 -*/
1.1464 -int sqlite3_open(
1.1465 - const char *filename, /* Database filename (UTF-8) */
1.1466 - sqlite3 **ppDb /* OUT: SQLite db handle */
1.1467 -);
1.1468 -int sqlite3_open16(
1.1469 - const void *filename, /* Database filename (UTF-16) */
1.1470 - sqlite3 **ppDb /* OUT: SQLite db handle */
1.1471 -);
1.1472 -int sqlite3_open_v2(
1.1473 - const char *filename, /* Database filename (UTF-8) */
1.1474 - sqlite3 **ppDb, /* OUT: SQLite db handle */
1.1475 - int flags, /* Flags */
1.1476 - const char *zVfs /* Name of VFS module to use */
1.1477 -);
1.1478 -
1.1479 -/*
1.1480 -** CAPI3REF: Error Codes And Messages
1.1481 -**
1.1482 -** The sqlite3_errcode() interface returns the numeric
1.1483 -** [SQLITE_OK | result code] or [SQLITE_IOERR_READ | extended result code]
1.1484 -** for the most recent failed sqlite3_* API call associated
1.1485 -** with [sqlite3] handle 'db'. If a prior API call failed but the
1.1486 -** most recent API call succeeded, the return value from sqlite3_errcode()
1.1487 -** is undefined.
1.1488 -**
1.1489 -** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
1.1490 -** text that describes the error, as either UTF8 or UTF16 respectively.
1.1491 -** Memory to hold the error message string is managed internally. The
1.1492 -** string may be overwritten or deallocated by subsequent calls to SQLite
1.1493 -** interface functions.
1.1494 -**
1.1495 -** Calls to many sqlite3_* functions set the error code and string returned
1.1496 -** by [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()]
1.1497 -** (overwriting the previous values). Note that calls to [sqlite3_errcode()],
1.1498 -** [sqlite3_errmsg()], and [sqlite3_errmsg16()] themselves do not affect the
1.1499 -** results of future invocations. Calls to API routines that do not return
1.1500 -** an error code (example: [sqlite3_data_count()]) do not
1.1501 -** change the error code returned by this routine. Interfaces that are
1.1502 -** not associated with a specific database connection (examples:
1.1503 -** [sqlite3_mprintf()] or [sqlite3_enable_shared_cache()] do not change
1.1504 -** the return code.
1.1505 -**
1.1506 -** Assuming no other intervening sqlite3_* API calls are made, the error
1.1507 -** code returned by this function is associated with the same error as
1.1508 -** the strings returned by [sqlite3_errmsg()] and [sqlite3_errmsg16()].
1.1509 -*/
1.1510 -int sqlite3_errcode(sqlite3 *db);
1.1511 -const char *sqlite3_errmsg(sqlite3*);
1.1512 -const void *sqlite3_errmsg16(sqlite3*);
1.1513 -
1.1514 -/*
1.1515 -** CAPI3REF: SQL Statement Object
1.1516 -**
1.1517 -** Instance of this object represent single SQL statements. This
1.1518 -** is variously known as a "prepared statement" or a
1.1519 -** "compiled SQL statement" or simply as a "statement".
1.1520 -**
1.1521 -** The life of a statement object goes something like this:
1.1522 -**
1.1523 -** <ol>
1.1524 -** <li> Create the object using [sqlite3_prepare_v2()] or a related
1.1525 -** function.
1.1526 -** <li> Bind values to host parameters using
1.1527 -** [sqlite3_bind_blob | sqlite3_bind_* interfaces].
1.1528 -** <li> Run the SQL by calling [sqlite3_step()] one or more times.
1.1529 -** <li> Reset the statement using [sqlite3_reset()] then go back
1.1530 -** to step 2. Do this zero or more times.
1.1531 -** <li> Destroy the object using [sqlite3_finalize()].
1.1532 -** </ol>
1.1533 -**
1.1534 -** Refer to documentation on individual methods above for additional
1.1535 -** information.
1.1536 -*/
1.1537 -typedef struct sqlite3_stmt sqlite3_stmt;
1.1538 -
1.1539 -/*
1.1540 -** CAPI3REF: Compiling An SQL Statement
1.1541 -**
1.1542 -** To execute an SQL query, it must first be compiled into a byte-code
1.1543 -** program using one of these routines.
1.1544 -**
1.1545 -** The first argument "db" is an [sqlite3 | SQLite database handle]
1.1546 -** obtained from a prior call to [sqlite3_open()], [sqlite3_open_v2()]
1.1547 -** or [sqlite3_open16()].
1.1548 -** The second argument "zSql" is the statement to be compiled, encoded
1.1549 -** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
1.1550 -** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2()
1.1551 -** use UTF-16.
1.1552 -**
1.1553 -** If the nByte argument is less
1.1554 -** than zero, then zSql is read up to the first zero terminator. If
1.1555 -** nByte is non-negative, then it is the maximum number of
1.1556 -** bytes read from zSql. When nByte is non-negative, the
1.1557 -** zSql string ends at either the first '\000' character or
1.1558 -** until the nByte-th byte, whichever comes first.
1.1559 -**
1.1560 -** *pzTail is made to point to the first byte past the end of the first
1.1561 -** SQL statement in zSql. This routine only compiles the first statement
1.1562 -** in zSql, so *pzTail is left pointing to what remains uncompiled.
1.1563 -**
1.1564 -** *ppStmt is left pointing to a compiled
1.1565 -** [sqlite3_stmt | SQL statement structure] that can be
1.1566 -** executed using [sqlite3_step()]. Or if there is an error, *ppStmt may be
1.1567 -** set to NULL. If the input text contained no SQL (if the input is and
1.1568 -** empty string or a comment) then *ppStmt is set to NULL. The calling
1.1569 -** procedure is responsible for deleting the compiled SQL statement
1.1570 -** using [sqlite3_finalize()] after it has finished with it.
1.1571 -**
1.1572 -** On success, [SQLITE_OK] is returned. Otherwise an
1.1573 -** [SQLITE_ERROR | error code] is returned.
1.1574 -**
1.1575 -** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
1.1576 -** recommended for all new programs. The two older interfaces are retained
1.1577 -** for backwards compatibility, but their use is discouraged.
1.1578 -** In the "v2" interfaces, the prepared statement
1.1579 -** that is returned (the [sqlite3_stmt] object) contains a copy of the
1.1580 -** original SQL text. This causes the [sqlite3_step()] interface to
1.1581 -** behave a differently in two ways:
1.1582 -**
1.1583 -** <ol>
1.1584 -** <li>
1.1585 -** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
1.1586 -** always used to do, [sqlite3_step()] will automatically recompile the SQL
1.1587 -** statement and try to run it again. If the schema has changed in a way
1.1588 -** that makes the statement no longer valid, [sqlite3_step()] will still
1.1589 -** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
1.1590 -** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
1.1591 -** error go away. Note: use [sqlite3_errmsg()] to find the text of the parsing
1.1592 -** error that results in an [SQLITE_SCHEMA] return.
1.1593 -** </li>
1.1594 -**
1.1595 -** <li>
1.1596 -** When an error occurs,
1.1597 -** [sqlite3_step()] will return one of the detailed
1.1598 -** [SQLITE_ERROR | result codes] or
1.1599 -** [SQLITE_IOERR_READ | extended result codes] such as directly.
1.1600 -** The legacy behavior was that [sqlite3_step()] would only return a generic
1.1601 -** [SQLITE_ERROR] result code and you would have to make a second call to
1.1602 -** [sqlite3_reset()] in order to find the underlying cause of the problem.
1.1603 -** With the "v2" prepare interfaces, the underlying reason for the error is
1.1604 -** returned immediately.
1.1605 -** </li>
1.1606 -** </ol>
1.1607 -*/
1.1608 -int sqlite3_prepare(
1.1609 - sqlite3 *db, /* Database handle */
1.1610 - const char *zSql, /* SQL statement, UTF-8 encoded */
1.1611 - int nByte, /* Maximum length of zSql in bytes. */
1.1612 - sqlite3_stmt **ppStmt, /* OUT: Statement handle */
1.1613 - const char **pzTail /* OUT: Pointer to unused portion of zSql */
1.1614 -);
1.1615 -int sqlite3_prepare_v2(
1.1616 - sqlite3 *db, /* Database handle */
1.1617 - const char *zSql, /* SQL statement, UTF-8 encoded */
1.1618 - int nByte, /* Maximum length of zSql in bytes. */
1.1619 - sqlite3_stmt **ppStmt, /* OUT: Statement handle */
1.1620 - const char **pzTail /* OUT: Pointer to unused portion of zSql */
1.1621 -);
1.1622 -int sqlite3_prepare16(
1.1623 - sqlite3 *db, /* Database handle */
1.1624 - const void *zSql, /* SQL statement, UTF-16 encoded */
1.1625 - int nByte, /* Maximum length of zSql in bytes. */
1.1626 - sqlite3_stmt **ppStmt, /* OUT: Statement handle */
1.1627 - const void **pzTail /* OUT: Pointer to unused portion of zSql */
1.1628 -);
1.1629 -int sqlite3_prepare16_v2(
1.1630 - sqlite3 *db, /* Database handle */
1.1631 - const void *zSql, /* SQL statement, UTF-16 encoded */
1.1632 - int nByte, /* Maximum length of zSql in bytes. */
1.1633 - sqlite3_stmt **ppStmt, /* OUT: Statement handle */
1.1634 - const void **pzTail /* OUT: Pointer to unused portion of zSql */
1.1635 -);
1.1636 -
1.1637 -/*
1.1638 -** CAPI3REF: Dynamically Typed Value Object
1.1639 -**
1.1640 -** SQLite uses dynamic typing for the values it stores. Values can
1.1641 -** be integers, floating point values, strings, BLOBs, or NULL. When
1.1642 -** passing around values internally, each value is represented as
1.1643 -** an instance of the sqlite3_value object.
1.1644 -*/
1.1645 -typedef struct Mem sqlite3_value;
1.1646 -
1.1647 -/*
1.1648 -** CAPI3REF: SQL Function Context Object
1.1649 -**
1.1650 -** The context in which an SQL function executes is stored in an
1.1651 -** sqlite3_context object. A pointer to such an object is the
1.1652 -** first parameter to user-defined SQL functions.
1.1653 -*/
1.1654 -typedef struct sqlite3_context sqlite3_context;
1.1655 -
1.1656 -/*
1.1657 -** CAPI3REF: Binding Values To Prepared Statements
1.1658 -**
1.1659 -** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
1.1660 -** one or more literals can be replace by a parameter in one of these
1.1661 -** forms:
1.1662 -**
1.1663 -** <ul>
1.1664 -** <li> ?
1.1665 -** <li> ?NNN
1.1666 -** <li> :AAA
1.1667 -** <li> @AAA
1.1668 -** <li> $VVV
1.1669 -** </ul>
1.1670 -**
1.1671 -** In the parameter forms shown above NNN is an integer literal,
1.1672 -** AAA is an alphanumeric identifier and VVV is a variable name according
1.1673 -** to the syntax rules of the TCL programming language.
1.1674 -** The values of these parameters (also called "host parameter names")
1.1675 -** can be set using the sqlite3_bind_*() routines defined here.
1.1676 -**
1.1677 -** The first argument to the sqlite3_bind_*() routines always is a pointer
1.1678 -** to the [sqlite3_stmt] object returned from [sqlite3_prepare_v2()] or
1.1679 -** its variants. The second
1.1680 -** argument is the index of the parameter to be set. The first parameter has
1.1681 -** an index of 1. When the same named parameter is used more than once, second
1.1682 -** and subsequent
1.1683 -** occurrences have the same index as the first occurrence. The index for
1.1684 -** named parameters can be looked up using the
1.1685 -** [sqlite3_bind_parameter_name()] API if desired. The index for "?NNN"
1.1686 -** parametes is the value of NNN.
1.1687 -** The NNN value must be between 1 and the compile-time
1.1688 -** parameter SQLITE_MAX_VARIABLE_NUMBER (default value: 999).
1.1689 -** See <a href="limits.html">limits.html</a> for additional information.
1.1690 -**
1.1691 -** The third argument is the value to bind to the parameter.
1.1692 -**
1.1693 -** In those
1.1694 -** routines that have a fourth argument, its value is the number of bytes
1.1695 -** in the parameter. To be clear: the value is the number of bytes in the
1.1696 -** string, not the number of characters. The number
1.1697 -** of bytes does not include the zero-terminator at the end of strings.
1.1698 -** If the fourth parameter is negative, the length of the string is
1.1699 -** number of bytes up to the first zero terminator.
1.1700 -**
1.1701 -** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
1.1702 -** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
1.1703 -** text after SQLite has finished with it. If the fifth argument is the
1.1704 -** special value [SQLITE_STATIC], then the library assumes that the information
1.1705 -** is in static, unmanaged space and does not need to be freed. If the
1.1706 -** fifth argument has the value [SQLITE_TRANSIENT], then SQLite makes its
1.1707 -** own private copy of the data immediately, before the sqlite3_bind_*()
1.1708 -** routine returns.
1.1709 -**
1.1710 -** The sqlite3_bind_zeroblob() routine binds a BLOB of length n that
1.1711 -** is filled with zeros. A zeroblob uses a fixed amount of memory
1.1712 -** (just an integer to hold it size) while it is being processed.
1.1713 -** Zeroblobs are intended to serve as place-holders for BLOBs whose
1.1714 -** content is later written using
1.1715 -** [sqlite3_blob_open | increment BLOB I/O] routines. A negative
1.1716 -** value for the zeroblob results in a zero-length BLOB.
1.1717 -**
1.1718 -** The sqlite3_bind_*() routines must be called after
1.1719 -** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
1.1720 -** before [sqlite3_step()].
1.1721 -** Bindings are not cleared by the [sqlite3_reset()] routine.
1.1722 -** Unbound parameters are interpreted as NULL.
1.1723 -**
1.1724 -** These routines return [SQLITE_OK] on success or an error code if
1.1725 -** anything goes wrong. [SQLITE_RANGE] is returned if the parameter
1.1726 -** index is out of range. [SQLITE_NOMEM] is returned if malloc fails.
1.1727 -** [SQLITE_MISUSE] is returned if these routines are called on a virtual
1.1728 -** machine that is the wrong state or which has already been finalized.
1.1729 -*/
1.1730 -int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
1.1731 -int sqlite3_bind_double(sqlite3_stmt*, int, double);
1.1732 -int sqlite3_bind_int(sqlite3_stmt*, int, int);
1.1733 -int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
1.1734 -int sqlite3_bind_null(sqlite3_stmt*, int);
1.1735 -int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
1.1736 -int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
1.1737 -int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
1.1738 -int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
1.1739 -
1.1740 -/*
1.1741 -** CAPI3REF: Number Of Host Parameters
1.1742 -**
1.1743 -** Return the largest host parameter index in the precompiled statement given
1.1744 -** as the argument. When the host parameters are of the forms like ":AAA"
1.1745 -** or "?", then they are assigned sequential increasing numbers beginning
1.1746 -** with one, so the value returned is the number of parameters. However
1.1747 -** if the same host parameter name is used multiple times, each occurrance
1.1748 -** is given the same number, so the value returned in that case is the number
1.1749 -** of unique host parameter names. If host parameters of the form "?NNN"
1.1750 -** are used (where NNN is an integer) then there might be gaps in the
1.1751 -** numbering and the value returned by this interface is the index of the
1.1752 -** host parameter with the largest index value.
1.1753 -**
1.1754 -** The prepared statement must not be [sqlite3_finalize | finalized]
1.1755 -** prior to this routine returnning. Otherwise the results are undefined
1.1756 -** and probably undesirable.
1.1757 -*/
1.1758 -int sqlite3_bind_parameter_count(sqlite3_stmt*);
1.1759 -
1.1760 -/*
1.1761 -** CAPI3REF: Name Of A Host Parameter
1.1762 -**
1.1763 -** This routine returns a pointer to the name of the n-th parameter in a
1.1764 -** [sqlite3_stmt | prepared statement].
1.1765 -** Host parameters of the form ":AAA" or "@AAA" or "$VVV" have a name
1.1766 -** which is the string ":AAA" or "@AAA" or "$VVV".
1.1767 -** In other words, the initial ":" or "$" or "@"
1.1768 -** is included as part of the name.
1.1769 -** Parameters of the form "?" or "?NNN" have no name.
1.1770 -**
1.1771 -** The first bound parameter has an index of 1, not 0.
1.1772 -**
1.1773 -** If the value n is out of range or if the n-th parameter is nameless,
1.1774 -** then NULL is returned. The returned string is always in the
1.1775 -** UTF-8 encoding even if the named parameter was originally specified
1.1776 -** as UTF-16 in [sqlite3_prepare16()] or [sqlite3_prepare16_v2()].
1.1777 -*/
1.1778 -const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
1.1779 -
1.1780 -/*
1.1781 -** CAPI3REF: Index Of A Parameter With A Given Name
1.1782 -**
1.1783 -** This routine returns the index of a host parameter with the given name.
1.1784 -** The name must match exactly. If no parameter with the given name is
1.1785 -** found, return 0. Parameter names must be UTF8.
1.1786 -*/
1.1787 -int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
1.1788 -
1.1789 -/*
1.1790 -** CAPI3REF: Reset All Bindings On A Prepared Statement
1.1791 -**
1.1792 -** Contrary to the intuition of many, [sqlite3_reset()] does not
1.1793 -** reset the [sqlite3_bind_blob | bindings] on a
1.1794 -** [sqlite3_stmt | prepared statement]. Use this routine to
1.1795 -** reset all host parameters to NULL.
1.1796 -*/
1.1797 -int sqlite3_clear_bindings(sqlite3_stmt*);
1.1798 -
1.1799 -/*
1.1800 -** CAPI3REF: Number Of Columns In A Result Set
1.1801 -**
1.1802 -** Return the number of columns in the result set returned by the
1.1803 -** [sqlite3_stmt | compiled SQL statement]. This routine returns 0
1.1804 -** if pStmt is an SQL statement that does not return data (for
1.1805 -** example an UPDATE).
1.1806 -*/
1.1807 -int sqlite3_column_count(sqlite3_stmt *pStmt);
1.1808 -
1.1809 -/*
1.1810 -** CAPI3REF: Column Names In A Result Set
1.1811 -**
1.1812 -** These routines return the name assigned to a particular column
1.1813 -** in the result set of a SELECT statement. The sqlite3_column_name()
1.1814 -** interface returns a pointer to a UTF8 string and sqlite3_column_name16()
1.1815 -** returns a pointer to a UTF16 string. The first parameter is the
1.1816 -** [sqlite3_stmt | prepared statement] that implements the SELECT statement.
1.1817 -** The second parameter is the column number. The left-most column is
1.1818 -** number 0.
1.1819 -**
1.1820 -** The returned string pointer is valid until either the
1.1821 -** [sqlite3_stmt | prepared statement] is destroyed by [sqlite3_finalize()]
1.1822 -** or until the next call sqlite3_column_name() or sqlite3_column_name16()
1.1823 -** on the same column.
1.1824 -**
1.1825 -** If sqlite3_malloc() fails during the processing of either routine
1.1826 -** (for example during a conversion from UTF-8 to UTF-16) then a
1.1827 -** NULL pointer is returned.
1.1828 -*/
1.1829 -const char *sqlite3_column_name(sqlite3_stmt*, int N);
1.1830 -const void *sqlite3_column_name16(sqlite3_stmt*, int N);
1.1831 -
1.1832 -/*
1.1833 -** CAPI3REF: Source Of Data In A Query Result
1.1834 -**
1.1835 -** These routines provide a means to determine what column of what
1.1836 -** table in which database a result of a SELECT statement comes from.
1.1837 -** The name of the database or table or column can be returned as
1.1838 -** either a UTF8 or UTF16 string. The _database_ routines return
1.1839 -** the database name, the _table_ routines return the table name, and
1.1840 -** the origin_ routines return the column name.
1.1841 -** The returned string is valid until
1.1842 -** the [sqlite3_stmt | prepared statement] is destroyed using
1.1843 -** [sqlite3_finalize()] or until the same information is requested
1.1844 -** again in a different encoding.
1.1845 -**
1.1846 -** The names returned are the original un-aliased names of the
1.1847 -** database, table, and column.
1.1848 -**
1.1849 -** The first argument to the following calls is a
1.1850 -** [sqlite3_stmt | compiled SQL statement].
1.1851 -** These functions return information about the Nth column returned by
1.1852 -** the statement, where N is the second function argument.
1.1853 -**
1.1854 -** If the Nth column returned by the statement is an expression
1.1855 -** or subquery and is not a column value, then all of these functions
1.1856 -** return NULL. Otherwise, they return the
1.1857 -** name of the attached database, table and column that query result
1.1858 -** column was extracted from.
1.1859 -**
1.1860 -** As with all other SQLite APIs, those postfixed with "16" return UTF-16
1.1861 -** encoded strings, the other functions return UTF-8.
1.1862 -**
1.1863 -** These APIs are only available if the library was compiled with the
1.1864 -** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
1.1865 -**
1.1866 -** If two or more threads call one or more of these routines against the same
1.1867 -** prepared statement and column at the same time then the results are
1.1868 -** undefined.
1.1869 -*/
1.1870 -const char *sqlite3_column_database_name(sqlite3_stmt*,int);
1.1871 -const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
1.1872 -const char *sqlite3_column_table_name(sqlite3_stmt*,int);
1.1873 -const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
1.1874 -const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
1.1875 -const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
1.1876 -
1.1877 -/*
1.1878 -** CAPI3REF: Declared Datatype Of A Query Result
1.1879 -**
1.1880 -** The first parameter is a [sqlite3_stmt | compiled SQL statement].
1.1881 -** If this statement is a SELECT statement and the Nth column of the
1.1882 -** returned result set of that SELECT is a table column (not an
1.1883 -** expression or subquery) then the declared type of the table
1.1884 -** column is returned. If the Nth column of the result set is an
1.1885 -** expression or subquery, then a NULL pointer is returned.
1.1886 -** The returned string is always UTF-8 encoded. For example, in
1.1887 -** the database schema:
1.1888 -**
1.1889 -** CREATE TABLE t1(c1 VARIANT);
1.1890 -**
1.1891 -** And the following statement compiled:
1.1892 -**
1.1893 -** SELECT c1 + 1, c1 FROM t1;
1.1894 -**
1.1895 -** Then this routine would return the string "VARIANT" for the second
1.1896 -** result column (i==1), and a NULL pointer for the first result column
1.1897 -** (i==0).
1.1898 -**
1.1899 -** SQLite uses dynamic run-time typing. So just because a column
1.1900 -** is declared to contain a particular type does not mean that the
1.1901 -** data stored in that column is of the declared type. SQLite is
1.1902 -** strongly typed, but the typing is dynamic not static. Type
1.1903 -** is associated with individual values, not with the containers
1.1904 -** used to hold those values.
1.1905 -*/
1.1906 -const char *sqlite3_column_decltype(sqlite3_stmt *, int i);
1.1907 -const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
1.1908 -
1.1909 -/*
1.1910 -** CAPI3REF: Evaluate An SQL Statement
1.1911 -**
1.1912 -** After an [sqlite3_stmt | SQL statement] has been prepared with a call
1.1913 -** to either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or to one of
1.1914 -** the legacy interfaces [sqlite3_prepare()] or [sqlite3_prepare16()],
1.1915 -** then this function must be called one or more times to evaluate the
1.1916 -** statement.
1.1917 -**
1.1918 -** The details of the behavior of this sqlite3_step() interface depend
1.1919 -** on whether the statement was prepared using the newer "v2" interface
1.1920 -** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
1.1921 -** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
1.1922 -** new "v2" interface is recommended for new applications but the legacy
1.1923 -** interface will continue to be supported.
1.1924 -**
1.1925 -** In the lagacy interface, the return value will be either [SQLITE_BUSY],
1.1926 -** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
1.1927 -** With the "v2" interface, any of the other [SQLITE_OK | result code]
1.1928 -** or [SQLITE_IOERR_READ | extended result code] might be returned as
1.1929 -** well.
1.1930 -**
1.1931 -** [SQLITE_BUSY] means that the database engine was unable to acquire the
1.1932 -** database locks it needs to do its job. If the statement is a COMMIT
1.1933 -** or occurs outside of an explicit transaction, then you can retry the
1.1934 -** statement. If the statement is not a COMMIT and occurs within a
1.1935 -** explicit transaction then you should rollback the transaction before
1.1936 -** continuing.
1.1937 -**
1.1938 -** [SQLITE_DONE] means that the statement has finished executing
1.1939 -** successfully. sqlite3_step() should not be called again on this virtual
1.1940 -** machine without first calling [sqlite3_reset()] to reset the virtual
1.1941 -** machine back to its initial state.
1.1942 -**
1.1943 -** If the SQL statement being executed returns any data, then
1.1944 -** [SQLITE_ROW] is returned each time a new row of data is ready
1.1945 -** for processing by the caller. The values may be accessed using
1.1946 -** the [sqlite3_column_int | column access functions].
1.1947 -** sqlite3_step() is called again to retrieve the next row of data.
1.1948 -**
1.1949 -** [SQLITE_ERROR] means that a run-time error (such as a constraint
1.1950 -** violation) has occurred. sqlite3_step() should not be called again on
1.1951 -** the VM. More information may be found by calling [sqlite3_errmsg()].
1.1952 -** With the legacy interface, a more specific error code (example:
1.1953 -** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
1.1954 -** can be obtained by calling [sqlite3_reset()] on the
1.1955 -** [sqlite3_stmt | prepared statement]. In the "v2" interface,
1.1956 -** the more specific error code is returned directly by sqlite3_step().
1.1957 -**
1.1958 -** [SQLITE_MISUSE] means that the this routine was called inappropriately.
1.1959 -** Perhaps it was called on a [sqlite3_stmt | prepared statement] that has
1.1960 -** already been [sqlite3_finalize | finalized] or on one that had
1.1961 -** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could
1.1962 -** be the case that the same database connection is being used by two or
1.1963 -** more threads at the same moment in time.
1.1964 -**
1.1965 -** <b>Goofy Interface Alert:</b>
1.1966 -** In the legacy interface,
1.1967 -** the sqlite3_step() API always returns a generic error code,
1.1968 -** [SQLITE_ERROR], following any error other than [SQLITE_BUSY]
1.1969 -** and [SQLITE_MISUSE]. You must call [sqlite3_reset()] or
1.1970 -** [sqlite3_finalize()] in order to find one of the specific
1.1971 -** [SQLITE_ERROR | result codes] that better describes the error.
1.1972 -** We admit that this is a goofy design. The problem has been fixed
1.1973 -** with the "v2" interface. If you prepare all of your SQL statements
1.1974 -** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
1.1975 -** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()], then the
1.1976 -** more specific [SQLITE_ERROR | result codes] are returned directly
1.1977 -** by sqlite3_step(). The use of the "v2" interface is recommended.
1.1978 -*/
1.1979 -int sqlite3_step(sqlite3_stmt*);
1.1980 -
1.1981 -/*
1.1982 -** CAPI3REF:
1.1983 -**
1.1984 -** Return the number of values in the current row of the result set.
1.1985 -**
1.1986 -** After a call to [sqlite3_step()] that returns [SQLITE_ROW], this routine
1.1987 -** will return the same value as the [sqlite3_column_count()] function.
1.1988 -** After [sqlite3_step()] has returned an [SQLITE_DONE], [SQLITE_BUSY], or
1.1989 -** a [SQLITE_ERROR | error code], or before [sqlite3_step()] has been
1.1990 -** called on the [sqlite3_stmt | prepared statement] for the first time,
1.1991 -** this routine returns zero.
1.1992 -*/
1.1993 -int sqlite3_data_count(sqlite3_stmt *pStmt);
1.1994 -
1.1995 -/*
1.1996 -** CAPI3REF: Fundamental Datatypes
1.1997 -**
1.1998 -** Every value in SQLite has one of five fundamental datatypes:
1.1999 -**
1.2000 -** <ul>
1.2001 -** <li> 64-bit signed integer
1.2002 -** <li> 64-bit IEEE floating point number
1.2003 -** <li> string
1.2004 -** <li> BLOB
1.2005 -** <li> NULL
1.2006 -** </ul>
1.2007 -**
1.2008 -** These constants are codes for each of those types.
1.2009 -**
1.2010 -** Note that the SQLITE_TEXT constant was also used in SQLite version 2
1.2011 -** for a completely different meaning. Software that links against both
1.2012 -** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT not
1.2013 -** SQLITE_TEXT.
1.2014 -*/
1.2015 -#define SQLITE_INTEGER 1
1.2016 -#define SQLITE_FLOAT 2
1.2017 -#define SQLITE_BLOB 4
1.2018 -#define SQLITE_NULL 5
1.2019 -#ifdef SQLITE_TEXT
1.2020 -# undef SQLITE_TEXT
1.2021 -#else
1.2022 -# define SQLITE_TEXT 3
1.2023 -#endif
1.2024 -#define SQLITE3_TEXT 3
1.2025 -
1.2026 -/*
1.2027 -** CAPI3REF: Results Values From A Query
1.2028 -**
1.2029 -** These routines return information about
1.2030 -** a single column of the current result row of a query. In every
1.2031 -** case the first argument is a pointer to the
1.2032 -** [sqlite3_stmt | SQL statement] that is being
1.2033 -** evaluated (the [sqlite3_stmt*] that was returned from
1.2034 -** [sqlite3_prepare_v2()] or one of its variants) and
1.2035 -** the second argument is the index of the column for which information
1.2036 -** should be returned. The left-most column of the result set
1.2037 -** has an index of 0.
1.2038 -**
1.2039 -** If the SQL statement is not currently point to a valid row, or if the
1.2040 -** the column index is out of range, the result is undefined.
1.2041 -** These routines may only be called when the most recent call to
1.2042 -** [sqlite3_step()] has returned [SQLITE_ROW] and neither
1.2043 -** [sqlite3_reset()] nor [sqlite3_finalize()] has been call subsequently.
1.2044 -** If any of these routines are called after [sqlite3_reset()] or
1.2045 -** [sqlite3_finalize()] or after [sqlite3_step()] has returned
1.2046 -** something other than [SQLITE_ROW], the results are undefined.
1.2047 -** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
1.2048 -** are called from a different thread while any of these routines
1.2049 -** are pending, then the results are undefined.
1.2050 -**
1.2051 -** The sqlite3_column_type() routine returns
1.2052 -** [SQLITE_INTEGER | datatype code] for the initial data type
1.2053 -** of the result column. The returned value is one of [SQLITE_INTEGER],
1.2054 -** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
1.2055 -** returned by sqlite3_column_type() is only meaningful if no type
1.2056 -** conversions have occurred as described below. After a type conversion,
1.2057 -** the value returned by sqlite3_column_type() is undefined. Future
1.2058 -** versions of SQLite may change the behavior of sqlite3_column_type()
1.2059 -** following a type conversion.
1.2060 -**
1.2061 -** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
1.2062 -** routine returns the number of bytes in that BLOB or string.
1.2063 -** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
1.2064 -** the string to UTF-8 and then returns the number of bytes.
1.2065 -** If the result is a numeric value then sqlite3_column_bytes() uses
1.2066 -** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
1.2067 -** the number of bytes in that string.
1.2068 -** The value returned does not include the zero terminator at the end
1.2069 -** of the string. For clarity: the value returned is the number of
1.2070 -** bytes in the string, not the number of characters.
1.2071 -**
1.2072 -** Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
1.2073 -** even zero-length strings, are always zero terminated. The return
1.2074 -** value from sqlite3_column_blob() for a zero-length blob is an arbitrary
1.2075 -** pointer, possibly even a NULL pointer.
1.2076 -**
1.2077 -** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
1.2078 -** but leaves the result in UTF-16 instead of UTF-8.
1.2079 -** The zero terminator is not included in this count.
1.2080 -**
1.2081 -** These routines attempt to convert the value where appropriate. For
1.2082 -** example, if the internal representation is FLOAT and a text result
1.2083 -** is requested, [sqlite3_snprintf()] is used internally to do the conversion
1.2084 -** automatically. The following table details the conversions that
1.2085 -** are applied:
1.2086 -**
1.2087 -** <blockquote>
1.2088 -** <table border="1">
1.2089 -** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
1.2090 -**
1.2091 -** <tr><td> NULL <td> INTEGER <td> Result is 0
1.2092 -** <tr><td> NULL <td> FLOAT <td> Result is 0.0
1.2093 -** <tr><td> NULL <td> TEXT <td> Result is NULL pointer
1.2094 -** <tr><td> NULL <td> BLOB <td> Result is NULL pointer
1.2095 -** <tr><td> INTEGER <td> FLOAT <td> Convert from integer to float
1.2096 -** <tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer
1.2097 -** <tr><td> INTEGER <td> BLOB <td> Same as for INTEGER->TEXT
1.2098 -** <tr><td> FLOAT <td> INTEGER <td> Convert from float to integer
1.2099 -** <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float
1.2100 -** <tr><td> FLOAT <td> BLOB <td> Same as FLOAT->TEXT
1.2101 -** <tr><td> TEXT <td> INTEGER <td> Use atoi()
1.2102 -** <tr><td> TEXT <td> FLOAT <td> Use atof()
1.2103 -** <tr><td> TEXT <td> BLOB <td> No change
1.2104 -** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
1.2105 -** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
1.2106 -** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
1.2107 -** </table>
1.2108 -** </blockquote>
1.2109 -**
1.2110 -** The table above makes reference to standard C library functions atoi()
1.2111 -** and atof(). SQLite does not really use these functions. It has its
1.2112 -** on equavalent internal routines. The atoi() and atof() names are
1.2113 -** used in the table for brevity and because they are familiar to most
1.2114 -** C programmers.
1.2115 -**
1.2116 -** Note that when type conversions occur, pointers returned by prior
1.2117 -** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
1.2118 -** sqlite3_column_text16() may be invalidated.
1.2119 -** Type conversions and pointer invalidations might occur
1.2120 -** in the following cases:
1.2121 -**
1.2122 -** <ul>
1.2123 -** <li><p> The initial content is a BLOB and sqlite3_column_text()
1.2124 -** or sqlite3_column_text16() is called. A zero-terminator might
1.2125 -** need to be added to the string.</p></li>
1.2126 -**
1.2127 -** <li><p> The initial content is UTF-8 text and sqlite3_column_bytes16() or
1.2128 -** sqlite3_column_text16() is called. The content must be converted
1.2129 -** to UTF-16.</p></li>
1.2130 -**
1.2131 -** <li><p> The initial content is UTF-16 text and sqlite3_column_bytes() or
1.2132 -** sqlite3_column_text() is called. The content must be converted
1.2133 -** to UTF-8.</p></li>
1.2134 -** </ul>
1.2135 -**
1.2136 -** Conversions between UTF-16be and UTF-16le are always done in place and do
1.2137 -** not invalidate a prior pointer, though of course the content of the buffer
1.2138 -** that the prior pointer points to will have been modified. Other kinds
1.2139 -** of conversion are done in place when it is possible, but sometime it is
1.2140 -** not possible and in those cases prior pointers are invalidated.
1.2141 -**
1.2142 -** The safest and easiest to remember policy is to invoke these routines
1.2143 -** in one of the following ways:
1.2144 -**
1.2145 -** <ul>
1.2146 -** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
1.2147 -** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
1.2148 -** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
1.2149 -** </ul>
1.2150 -**
1.2151 -** In other words, you should call sqlite3_column_text(), sqlite3_column_blob(),
1.2152 -** or sqlite3_column_text16() first to force the result into the desired
1.2153 -** format, then invoke sqlite3_column_bytes() or sqlite3_column_bytes16() to
1.2154 -** find the size of the result. Do not mix call to sqlite3_column_text() or
1.2155 -** sqlite3_column_blob() with calls to sqlite3_column_bytes16(). And do not
1.2156 -** mix calls to sqlite3_column_text16() with calls to sqlite3_column_bytes().
1.2157 -**
1.2158 -** The pointers returned are valid until a type conversion occurs as
1.2159 -** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
1.2160 -** [sqlite3_finalize()] is called. The memory space used to hold strings
1.2161 -** and blobs is freed automatically. Do <b>not</b> pass the pointers returned
1.2162 -** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
1.2163 -** [sqlite3_free()].
1.2164 -**
1.2165 -** If a memory allocation error occurs during the evaluation of any
1.2166 -** of these routines, a default value is returned. The default value
1.2167 -** is either the integer 0, the floating point number 0.0, or a NULL
1.2168 -** pointer. Subsequent calls to [sqlite3_errcode()] will return
1.2169 -** [SQLITE_NOMEM].
1.2170 -*/
1.2171 -const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
1.2172 -int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
1.2173 -int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
1.2174 -double sqlite3_column_double(sqlite3_stmt*, int iCol);
1.2175 -int sqlite3_column_int(sqlite3_stmt*, int iCol);
1.2176 -sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
1.2177 -const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
1.2178 -const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
1.2179 -int sqlite3_column_type(sqlite3_stmt*, int iCol);
1.2180 -sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
1.2181 -
1.2182 -/*
1.2183 -** CAPI3REF: Destroy A Prepared Statement Object
1.2184 -**
1.2185 -** The sqlite3_finalize() function is called to delete a
1.2186 -** [sqlite3_stmt | compiled SQL statement]. If the statement was
1.2187 -** executed successfully, or not executed at all, then SQLITE_OK is returned.
1.2188 -** If execution of the statement failed then an
1.2189 -** [SQLITE_ERROR | error code] or [SQLITE_IOERR_READ | extended error code]
1.2190 -** is returned.
1.2191 -**
1.2192 -** This routine can be called at any point during the execution of the
1.2193 -** [sqlite3_stmt | virtual machine]. If the virtual machine has not
1.2194 -** completed execution when this routine is called, that is like
1.2195 -** encountering an error or an interrupt. (See [sqlite3_interrupt()].)
1.2196 -** Incomplete updates may be rolled back and transactions cancelled,
1.2197 -** depending on the circumstances, and the
1.2198 -** [SQLITE_ERROR | result code] returned will be [SQLITE_ABORT].
1.2199 -*/
1.2200 -int sqlite3_finalize(sqlite3_stmt *pStmt);
1.2201 -
1.2202 -/*
1.2203 -** CAPI3REF: Reset A Prepared Statement Object
1.2204 -**
1.2205 -** The sqlite3_reset() function is called to reset a
1.2206 -** [sqlite3_stmt | compiled SQL statement] object.
1.2207 -** back to it's initial state, ready to be re-executed.
1.2208 -** Any SQL statement variables that had values bound to them using
1.2209 -** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
1.2210 -** Use [sqlite3_clear_bindings()] to reset the bindings.
1.2211 -*/
1.2212 -int sqlite3_reset(sqlite3_stmt *pStmt);
1.2213 -
1.2214 -/*
1.2215 -** CAPI3REF: Create Or Redefine SQL Functions
1.2216 -**
1.2217 -** The following two functions are used to add SQL functions or aggregates
1.2218 -** or to redefine the behavior of existing SQL functions or aggregates. The
1.2219 -** difference only between the two is that the second parameter, the
1.2220 -** name of the (scalar) function or aggregate, is encoded in UTF-8 for
1.2221 -** sqlite3_create_function() and UTF-16 for sqlite3_create_function16().
1.2222 -**
1.2223 -** The first argument is the [sqlite3 | database handle] that holds the
1.2224 -** SQL function or aggregate is to be added or redefined. If a single
1.2225 -** program uses more than one database handle internally, then SQL
1.2226 -** functions or aggregates must be added individually to each database
1.2227 -** handle with which they will be used.
1.2228 -**
1.2229 -** The second parameter is the name of the SQL function to be created
1.2230 -** or redefined.
1.2231 -** The length of the name is limited to 255 bytes, exclusive of the
1.2232 -** zero-terminator. Note that the name length limit is in bytes, not
1.2233 -** characters. Any attempt to create a function with a longer name
1.2234 -** will result in an SQLITE_ERROR error.
1.2235 -**
1.2236 -** The third parameter is the number of arguments that the SQL function or
1.2237 -** aggregate takes. If this parameter is negative, then the SQL function or
1.2238 -** aggregate may take any number of arguments.
1.2239 -**
1.2240 -** The fourth parameter, eTextRep, specifies what
1.2241 -** [SQLITE_UTF8 | text encoding] this SQL function prefers for
1.2242 -** its parameters. Any SQL function implementation should be able to work
1.2243 -** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
1.2244 -** more efficient with one encoding than another. It is allowed to
1.2245 -** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
1.2246 -** times with the same function but with different values of eTextRep.
1.2247 -** When multiple implementations of the same function are available, SQLite
1.2248 -** will pick the one that involves the least amount of data conversion.
1.2249 -** If there is only a single implementation which does not care what
1.2250 -** text encoding is used, then the fourth argument should be
1.2251 -** [SQLITE_ANY].
1.2252 -**
1.2253 -** The fifth parameter is an arbitrary pointer. The implementation
1.2254 -** of the function can gain access to this pointer using
1.2255 -** [sqlite3_user_data()].
1.2256 -**
1.2257 -** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
1.2258 -** pointers to C-language functions that implement the SQL
1.2259 -** function or aggregate. A scalar SQL function requires an implementation of
1.2260 -** the xFunc callback only, NULL pointers should be passed as the xStep
1.2261 -** and xFinal parameters. An aggregate SQL function requires an implementation
1.2262 -** of xStep and xFinal and NULL should be passed for xFunc. To delete an
1.2263 -** existing SQL function or aggregate, pass NULL for all three function
1.2264 -** callback.
1.2265 -**
1.2266 -** It is permitted to register multiple implementations of the same
1.2267 -** functions with the same name but with either differing numbers of
1.2268 -** arguments or differing perferred text encodings. SQLite will use
1.2269 -** the implementation most closely matches the way in which the
1.2270 -** SQL function is used.
1.2271 -*/
1.2272 -int sqlite3_create_function(
1.2273 - sqlite3 *,
1.2274 - const char *zFunctionName,
1.2275 - int nArg,
1.2276 - int eTextRep,
1.2277 - void*,
1.2278 - void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
1.2279 - void (*xStep)(sqlite3_context*,int,sqlite3_value**),
1.2280 - void (*xFinal)(sqlite3_context*)
1.2281 -);
1.2282 -int sqlite3_create_function16(
1.2283 - sqlite3*,
1.2284 - const void *zFunctionName,
1.2285 - int nArg,
1.2286 - int eTextRep,
1.2287 - void*,
1.2288 - void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
1.2289 - void (*xStep)(sqlite3_context*,int,sqlite3_value**),
1.2290 - void (*xFinal)(sqlite3_context*)
1.2291 -);
1.2292 -
1.2293 -/*
1.2294 -** CAPI3REF: Text Encodings
1.2295 -**
1.2296 -** These constant define integer codes that represent the various
1.2297 -** text encodings supported by SQLite.
1.2298 -*/
1.2299 -#define SQLITE_UTF8 1
1.2300 -#define SQLITE_UTF16LE 2
1.2301 -#define SQLITE_UTF16BE 3
1.2302 -#define SQLITE_UTF16 4 /* Use native byte order */
1.2303 -#define SQLITE_ANY 5 /* sqlite3_create_function only */
1.2304 -#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
1.2305 -
1.2306 -/*
1.2307 -** CAPI3REF: Obsolete Functions
1.2308 -**
1.2309 -** These functions are all now obsolete. In order to maintain
1.2310 -** backwards compatibility with older code, we continue to support
1.2311 -** these functions. However, new development projects should avoid
1.2312 -** the use of these functions. To help encourage people to avoid
1.2313 -** using these functions, we are not going to tell you want they do.
1.2314 -*/
1.2315 -int sqlite3_aggregate_count(sqlite3_context*);
1.2316 -int sqlite3_expired(sqlite3_stmt*);
1.2317 -int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
1.2318 -int sqlite3_global_recover(void);
1.2319 -void sqlite3_thread_cleanup(void);
1.2320 -
1.2321 -/*
1.2322 -** CAPI3REF: Obtaining SQL Function Parameter Values
1.2323 -**
1.2324 -** The C-language implementation of SQL functions and aggregates uses
1.2325 -** this set of interface routines to access the parameter values on
1.2326 -** the function or aggregate.
1.2327 -**
1.2328 -** The xFunc (for scalar functions) or xStep (for aggregates) parameters
1.2329 -** to [sqlite3_create_function()] and [sqlite3_create_function16()]
1.2330 -** define callbacks that implement the SQL functions and aggregates.
1.2331 -** The 4th parameter to these callbacks is an array of pointers to
1.2332 -** [sqlite3_value] objects. There is one [sqlite3_value] object for
1.2333 -** each parameter to the SQL function. These routines are used to
1.2334 -** extract values from the [sqlite3_value] objects.
1.2335 -**
1.2336 -** These routines work just like the corresponding
1.2337 -** [sqlite3_column_blob | sqlite3_column_* routines] except that
1.2338 -** these routines take a single [sqlite3_value*] pointer instead
1.2339 -** of an [sqlite3_stmt*] pointer and an integer column number.
1.2340 -**
1.2341 -** The sqlite3_value_text16() interface extracts a UTF16 string
1.2342 -** in the native byte-order of the host machine. The
1.2343 -** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
1.2344 -** extract UTF16 strings as big-endian and little-endian respectively.
1.2345 -**
1.2346 -** The sqlite3_value_numeric_type() interface attempts to apply
1.2347 -** numeric affinity to the value. This means that an attempt is
1.2348 -** made to convert the value to an integer or floating point. If
1.2349 -** such a conversion is possible without loss of information (in order
1.2350 -** words if the value is original a string that looks like a number)
1.2351 -** then it is done. Otherwise no conversion occurs. The
1.2352 -** [SQLITE_INTEGER | datatype] after conversion is returned.
1.2353 -**
1.2354 -** Please pay particular attention to the fact that the pointer that
1.2355 -** is returned from [sqlite3_value_blob()], [sqlite3_value_text()], or
1.2356 -** [sqlite3_value_text16()] can be invalidated by a subsequent call to
1.2357 -** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
1.2358 -** or [sqlite3_value_text16()].
1.2359 -**
1.2360 -** These routines must be called from the same thread as
1.2361 -** the SQL function that supplied the sqlite3_value* parameters.
1.2362 -** Or, if the sqlite3_value* argument comes from the [sqlite3_column_value()]
1.2363 -** interface, then these routines should be called from the same thread
1.2364 -** that ran [sqlite3_column_value()].
1.2365 -*/
1.2366 -const void *sqlite3_value_blob(sqlite3_value*);
1.2367 -int sqlite3_value_bytes(sqlite3_value*);
1.2368 -int sqlite3_value_bytes16(sqlite3_value*);
1.2369 -double sqlite3_value_double(sqlite3_value*);
1.2370 -int sqlite3_value_int(sqlite3_value*);
1.2371 -sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
1.2372 -const unsigned char *sqlite3_value_text(sqlite3_value*);
1.2373 -const void *sqlite3_value_text16(sqlite3_value*);
1.2374 -const void *sqlite3_value_text16le(sqlite3_value*);
1.2375 -const void *sqlite3_value_text16be(sqlite3_value*);
1.2376 -int sqlite3_value_type(sqlite3_value*);
1.2377 -int sqlite3_value_numeric_type(sqlite3_value*);
1.2378 -
1.2379 -/*
1.2380 -** CAPI3REF: Obtain Aggregate Function Context
1.2381 -**
1.2382 -** The implementation of aggregate SQL functions use this routine to allocate
1.2383 -** a structure for storing their state. The first time this routine
1.2384 -** is called for a particular aggregate, a new structure of size nBytes
1.2385 -** is allocated, zeroed, and returned. On subsequent calls (for the
1.2386 -** same aggregate instance) the same buffer is returned. The implementation
1.2387 -** of the aggregate can use the returned buffer to accumulate data.
1.2388 -**
1.2389 -** The buffer allocated is freed automatically by SQLite whan the aggregate
1.2390 -** query concludes.
1.2391 -**
1.2392 -** The first parameter should be a copy of the
1.2393 -** [sqlite3_context | SQL function context] that is the first
1.2394 -** parameter to the callback routine that implements the aggregate
1.2395 -** function.
1.2396 -**
1.2397 -** This routine must be called from the same thread in which
1.2398 -** the aggregate SQL function is running.
1.2399 -*/
1.2400 -void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
1.2401 -
1.2402 -/*
1.2403 -** CAPI3REF: User Data For Functions
1.2404 -**
1.2405 -** The pUserData parameter to the [sqlite3_create_function()]
1.2406 -** and [sqlite3_create_function16()] routines
1.2407 -** used to register user functions is available to
1.2408 -** the implementation of the function using this call.
1.2409 -**
1.2410 -** This routine must be called from the same thread in which
1.2411 -** the SQL function is running.
1.2412 -*/
1.2413 -void *sqlite3_user_data(sqlite3_context*);
1.2414 -
1.2415 -/*
1.2416 -** CAPI3REF: Function Auxiliary Data
1.2417 -**
1.2418 -** The following two functions may be used by scalar SQL functions to
1.2419 -** associate meta-data with argument values. If the same value is passed to
1.2420 -** multiple invocations of the same SQL function during query execution, under
1.2421 -** some circumstances the associated meta-data may be preserved. This may
1.2422 -** be used, for example, to add a regular-expression matching scalar
1.2423 -** function. The compiled version of the regular expression is stored as
1.2424 -** meta-data associated with the SQL value passed as the regular expression
1.2425 -** pattern. The compiled regular expression can be reused on multiple
1.2426 -** invocations of the same function so that the original pattern string
1.2427 -** does not need to be recompiled on each invocation.
1.2428 -**
1.2429 -** The sqlite3_get_auxdata() interface returns a pointer to the meta-data
1.2430 -** associated with the Nth argument value to the current SQL function
1.2431 -** call, where N is the second parameter. If no meta-data has been set for
1.2432 -** that value, then a NULL pointer is returned.
1.2433 -**
1.2434 -** The sqlite3_set_auxdata() is used to associate meta-data with an SQL
1.2435 -** function argument. The third parameter is a pointer to the meta-data
1.2436 -** to be associated with the Nth user function argument value. The fourth
1.2437 -** parameter specifies a destructor that will be called on the meta-
1.2438 -** data pointer to release it when it is no longer required. If the
1.2439 -** destructor is NULL, it is not invoked.
1.2440 -**
1.2441 -** In practice, meta-data is preserved between function calls for
1.2442 -** expressions that are constant at compile time. This includes literal
1.2443 -** values and SQL variables.
1.2444 -**
1.2445 -** These routines must be called from the same thread in which
1.2446 -** the SQL function is running.
1.2447 -*/
1.2448 -void *sqlite3_get_auxdata(sqlite3_context*, int);
1.2449 -void sqlite3_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));
1.2450 -
1.2451 -
1.2452 -/*
1.2453 -** CAPI3REF: Constants Defining Special Destructor Behavior
1.2454 -**
1.2455 -** These are special value for the destructor that is passed in as the
1.2456 -** final argument to routines like [sqlite3_result_blob()]. If the destructor
1.2457 -** argument is SQLITE_STATIC, it means that the content pointer is constant
1.2458 -** and will never change. It does not need to be destroyed. The
1.2459 -** SQLITE_TRANSIENT value means that the content will likely change in
1.2460 -** the near future and that SQLite should make its own private copy of
1.2461 -** the content before returning.
1.2462 -**
1.2463 -** The typedef is necessary to work around problems in certain
1.2464 -** C++ compilers. See ticket #2191.
1.2465 -*/
1.2466 -typedef void (*sqlite3_destructor_type)(void*);
1.2467 -#define SQLITE_STATIC ((sqlite3_destructor_type)0)
1.2468 -#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
1.2469 -
1.2470 -/*
1.2471 -** CAPI3REF: Setting The Result Of An SQL Function
1.2472 -**
1.2473 -** These routines are used by the xFunc or xFinal callbacks that
1.2474 -** implement SQL functions and aggregates. See
1.2475 -** [sqlite3_create_function()] and [sqlite3_create_function16()]
1.2476 -** for additional information.
1.2477 -**
1.2478 -** These functions work very much like the
1.2479 -** [sqlite3_bind_blob | sqlite3_bind_*] family of functions used
1.2480 -** to bind values to host parameters in prepared statements.
1.2481 -** Refer to the
1.2482 -** [sqlite3_bind_blob | sqlite3_bind_* documentation] for
1.2483 -** additional information.
1.2484 -**
1.2485 -** The sqlite3_result_error() and sqlite3_result_error16() functions
1.2486 -** cause the implemented SQL function to throw an exception. The
1.2487 -** parameter to sqlite3_result_error() or sqlite3_result_error16()
1.2488 -** is the text of an error message.
1.2489 -**
1.2490 -** The sqlite3_result_toobig() cause the function implementation
1.2491 -** to throw and error indicating that a string or BLOB is to long
1.2492 -** to represent.
1.2493 -**
1.2494 -** These routines must be called from within the same thread as
1.2495 -** the SQL function associated with the [sqlite3_context] pointer.
1.2496 -*/
1.2497 -void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
1.2498 -void sqlite3_result_double(sqlite3_context*, double);
1.2499 -void sqlite3_result_error(sqlite3_context*, const char*, int);
1.2500 -void sqlite3_result_error16(sqlite3_context*, const void*, int);
1.2501 -void sqlite3_result_error_toobig(sqlite3_context*);
1.2502 -void sqlite3_result_error_nomem(sqlite3_context*);
1.2503 -void sqlite3_result_int(sqlite3_context*, int);
1.2504 -void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
1.2505 -void sqlite3_result_null(sqlite3_context*);
1.2506 -void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
1.2507 -void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
1.2508 -void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
1.2509 -void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
1.2510 -void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
1.2511 -void sqlite3_result_zeroblob(sqlite3_context*, int n);
1.2512 -
1.2513 -/*
1.2514 -** CAPI3REF: Define New Collating Sequences
1.2515 -**
1.2516 -** These functions are used to add new collation sequences to the
1.2517 -** [sqlite3*] handle specified as the first argument.
1.2518 -**
1.2519 -** The name of the new collation sequence is specified as a UTF-8 string
1.2520 -** for sqlite3_create_collation() and sqlite3_create_collation_v2()
1.2521 -** and a UTF-16 string for sqlite3_create_collation16(). In all cases
1.2522 -** the name is passed as the second function argument.
1.2523 -**
1.2524 -** The third argument must be one of the constants [SQLITE_UTF8],
1.2525 -** [SQLITE_UTF16LE] or [SQLITE_UTF16BE], indicating that the user-supplied
1.2526 -** routine expects to be passed pointers to strings encoded using UTF-8,
1.2527 -** UTF-16 little-endian or UTF-16 big-endian respectively.
1.2528 -**
1.2529 -** A pointer to the user supplied routine must be passed as the fifth
1.2530 -** argument. If it is NULL, this is the same as deleting the collation
1.2531 -** sequence (so that SQLite cannot call it anymore). Each time the user
1.2532 -** supplied function is invoked, it is passed a copy of the void* passed as
1.2533 -** the fourth argument to sqlite3_create_collation() or
1.2534 -** sqlite3_create_collation16() as its first parameter.
1.2535 -**
1.2536 -** The remaining arguments to the user-supplied routine are two strings,
1.2537 -** each represented by a [length, data] pair and encoded in the encoding
1.2538 -** that was passed as the third argument when the collation sequence was
1.2539 -** registered. The user routine should return negative, zero or positive if
1.2540 -** the first string is less than, equal to, or greater than the second
1.2541 -** string. i.e. (STRING1 - STRING2).
1.2542 -**
1.2543 -** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
1.2544 -** excapt that it takes an extra argument which is a destructor for
1.2545 -** the collation. The destructor is called when the collation is
1.2546 -** destroyed and is passed a copy of the fourth parameter void* pointer
1.2547 -** of the sqlite3_create_collation_v2(). Collations are destroyed when
1.2548 -** they are overridden by later calls to the collation creation functions
1.2549 -** or when the [sqlite3*] database handle is closed using [sqlite3_close()].
1.2550 -**
1.2551 -** The sqlite3_create_collation_v2() interface is experimental and
1.2552 -** subject to change in future releases. The other collation creation
1.2553 -** functions are stable.
1.2554 -*/
1.2555 -int sqlite3_create_collation(
1.2556 - sqlite3*,
1.2557 - const char *zName,
1.2558 - int eTextRep,
1.2559 - void*,
1.2560 - int(*xCompare)(void*,int,const void*,int,const void*)
1.2561 -);
1.2562 -int sqlite3_create_collation_v2(
1.2563 - sqlite3*,
1.2564 - const char *zName,
1.2565 - int eTextRep,
1.2566 - void*,
1.2567 - int(*xCompare)(void*,int,const void*,int,const void*),
1.2568 - void(*xDestroy)(void*)
1.2569 -);
1.2570 -int sqlite3_create_collation16(
1.2571 - sqlite3*,
1.2572 - const char *zName,
1.2573 - int eTextRep,
1.2574 - void*,
1.2575 - int(*xCompare)(void*,int,const void*,int,const void*)
1.2576 -);
1.2577 -
1.2578 -/*
1.2579 -** CAPI3REF: Collation Needed Callbacks
1.2580 -**
1.2581 -** To avoid having to register all collation sequences before a database
1.2582 -** can be used, a single callback function may be registered with the
1.2583 -** database handle to be called whenever an undefined collation sequence is
1.2584 -** required.
1.2585 -**
1.2586 -** If the function is registered using the sqlite3_collation_needed() API,
1.2587 -** then it is passed the names of undefined collation sequences as strings
1.2588 -** encoded in UTF-8. If sqlite3_collation_needed16() is used, the names
1.2589 -** are passed as UTF-16 in machine native byte order. A call to either
1.2590 -** function replaces any existing callback.
1.2591 -**
1.2592 -** When the callback is invoked, the first argument passed is a copy
1.2593 -** of the second argument to sqlite3_collation_needed() or
1.2594 -** sqlite3_collation_needed16(). The second argument is the database
1.2595 -** handle. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], or
1.2596 -** [SQLITE_UTF16LE], indicating the most desirable form of the collation
1.2597 -** sequence function required. The fourth parameter is the name of the
1.2598 -** required collation sequence.
1.2599 -**
1.2600 -** The callback function should register the desired collation using
1.2601 -** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
1.2602 -** [sqlite3_create_collation_v2()].
1.2603 -*/
1.2604 -int sqlite3_collation_needed(
1.2605 - sqlite3*,
1.2606 - void*,
1.2607 - void(*)(void*,sqlite3*,int eTextRep,const char*)
1.2608 -);
1.2609 -int sqlite3_collation_needed16(
1.2610 - sqlite3*,
1.2611 - void*,
1.2612 - void(*)(void*,sqlite3*,int eTextRep,const void*)
1.2613 -);
1.2614 -
1.2615 -/*
1.2616 -** Specify the key for an encrypted database. This routine should be
1.2617 -** called right after sqlite3_open().
1.2618 -**
1.2619 -** The code to implement this API is not available in the public release
1.2620 -** of SQLite.
1.2621 -*/
1.2622 -int sqlite3_key(
1.2623 - sqlite3 *db, /* Database to be rekeyed */
1.2624 - const void *pKey, int nKey /* The key */
1.2625 -);
1.2626 -
1.2627 -/*
1.2628 -** Change the key on an open database. If the current database is not
1.2629 -** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
1.2630 -** database is decrypted.
1.2631 -**
1.2632 -** The code to implement this API is not available in the public release
1.2633 -** of SQLite.
1.2634 -*/
1.2635 -int sqlite3_rekey(
1.2636 - sqlite3 *db, /* Database to be rekeyed */
1.2637 - const void *pKey, int nKey /* The new key */
1.2638 -);
1.2639 -
1.2640 -/*
1.2641 -** CAPI3REF: Suspend Execution For A Short Time
1.2642 -**
1.2643 -** This function causes the current thread to suspend execution
1.2644 -** a number of milliseconds specified in its parameter.
1.2645 -**
1.2646 -** If the operating system does not support sleep requests with
1.2647 -** millisecond time resolution, then the time will be rounded up to
1.2648 -** the nearest second. The number of milliseconds of sleep actually
1.2649 -** requested from the operating system is returned.
1.2650 -**
1.2651 -** SQLite implements this interface by calling the xSleep()
1.2652 -** method of the default [sqlite3_vfs] object.
1.2653 -*/
1.2654 -int sqlite3_sleep(int);
1.2655 -
1.2656 -/*
1.2657 -** CAPI3REF: Name Of The Folder Holding Temporary Files
1.2658 -**
1.2659 -** If this global variable is made to point to a string which is
1.2660 -** the name of a folder (a.ka. directory), then all temporary files
1.2661 -** created by SQLite will be placed in that directory. If this variable
1.2662 -** is NULL pointer, then SQLite does a search for an appropriate temporary
1.2663 -** file directory.
1.2664 -**
1.2665 -** It is not safe to modify this variable once a database connection
1.2666 -** has been opened. It is intended that this variable be set once
1.2667 -** as part of process initialization and before any SQLite interface
1.2668 -** routines have been call and remain unchanged thereafter.
1.2669 -*/
1.2670 -SQLITE_EXTERN char *sqlite3_temp_directory;
1.2671 -
1.2672 -/*
1.2673 -** CAPI3REF: Test To See If The Database Is In Auto-Commit Mode
1.2674 -**
1.2675 -** Test to see whether or not the database connection is in autocommit
1.2676 -** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
1.2677 -** by default. Autocommit is disabled by a BEGIN statement and reenabled
1.2678 -** by the next COMMIT or ROLLBACK.
1.2679 -**
1.2680 -** If certain kinds of errors occur on a statement within a multi-statement
1.2681 -** transactions (errors including [SQLITE_FULL], [SQLITE_IOERR],
1.2682 -** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
1.2683 -** transaction might be rolled back automatically. The only way to
1.2684 -** find out if SQLite automatically rolled back the transaction after
1.2685 -** an error is to use this function.
1.2686 -**
1.2687 -** If another thread changes the autocommit status of the database
1.2688 -** connection while this routine is running, then the return value
1.2689 -** is undefined.
1.2690 -*/
1.2691 -int sqlite3_get_autocommit(sqlite3*);
1.2692 -
1.2693 -/*
1.2694 -** CAPI3REF: Find The Database Handle Associated With A Prepared Statement
1.2695 -**
1.2696 -** Return the [sqlite3*] database handle to which a
1.2697 -** [sqlite3_stmt | prepared statement] belongs.
1.2698 -** This is the same database handle that was
1.2699 -** the first argument to the [sqlite3_prepare_v2()] or its variants
1.2700 -** that was used to create the statement in the first place.
1.2701 -*/
1.2702 -sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
1.2703 -
1.2704 -
1.2705 -/*
1.2706 -** CAPI3REF: Commit And Rollback Notification Callbacks
1.2707 -**
1.2708 -** These routines
1.2709 -** register callback functions to be invoked whenever a transaction
1.2710 -** is committed or rolled back. The pArg argument is passed through
1.2711 -** to the callback. If the callback on a commit hook function
1.2712 -** returns non-zero, then the commit is converted into a rollback.
1.2713 -**
1.2714 -** If another function was previously registered, its pArg value is returned.
1.2715 -** Otherwise NULL is returned.
1.2716 -**
1.2717 -** Registering a NULL function disables the callback.
1.2718 -**
1.2719 -** For the purposes of this API, a transaction is said to have been
1.2720 -** rolled back if an explicit "ROLLBACK" statement is executed, or
1.2721 -** an error or constraint causes an implicit rollback to occur. The
1.2722 -** callback is not invoked if a transaction is automatically rolled
1.2723 -** back because the database connection is closed.
1.2724 -**
1.2725 -** These are experimental interfaces and are subject to change.
1.2726 -*/
1.2727 -void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
1.2728 -void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
1.2729 -
1.2730 -/*
1.2731 -** CAPI3REF: Data Change Notification Callbacks
1.2732 -**
1.2733 -** Register a callback function with the database connection identified by the
1.2734 -** first argument to be invoked whenever a row is updated, inserted or deleted.
1.2735 -** Any callback set by a previous call to this function for the same
1.2736 -** database connection is overridden.
1.2737 -**
1.2738 -** The second argument is a pointer to the function to invoke when a
1.2739 -** row is updated, inserted or deleted. The first argument to the callback is
1.2740 -** a copy of the third argument to sqlite3_update_hook(). The second callback
1.2741 -** argument is one of SQLITE_INSERT, SQLITE_DELETE or SQLITE_UPDATE, depending
1.2742 -** on the operation that caused the callback to be invoked. The third and
1.2743 -** fourth arguments to the callback contain pointers to the database and
1.2744 -** table name containing the affected row. The final callback parameter is
1.2745 -** the rowid of the row. In the case of an update, this is the rowid after
1.2746 -** the update takes place.
1.2747 -**
1.2748 -** The update hook is not invoked when internal system tables are
1.2749 -** modified (i.e. sqlite_master and sqlite_sequence).
1.2750 -**
1.2751 -** If another function was previously registered, its pArg value is returned.
1.2752 -** Otherwise NULL is returned.
1.2753 -*/
1.2754 -void *sqlite3_update_hook(
1.2755 - sqlite3*,
1.2756 - void(*)(void *,int ,char const *,char const *,sqlite3_int64),
1.2757 - void*
1.2758 -);
1.2759 -
1.2760 -/*
1.2761 -** CAPI3REF: Enable Or Disable Shared Pager Cache
1.2762 -**
1.2763 -** This routine enables or disables the sharing of the database cache
1.2764 -** and schema data structures between connections to the same database.
1.2765 -** Sharing is enabled if the argument is true and disabled if the argument
1.2766 -** is false.
1.2767 -**
1.2768 -** Beginning in SQLite version 3.5.0, cache sharing is enabled and disabled
1.2769 -** for an entire process. In prior versions of SQLite, sharing was
1.2770 -** enabled or disabled for each thread separately.
1.2771 -**
1.2772 -** The cache sharing mode set by this interface effects all subsequent
1.2773 -** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
1.2774 -** Existing database connections continue use the sharing mode that was
1.2775 -** in effect at the time they were opened.
1.2776 -**
1.2777 -** Virtual tables cannot be used with a shared cache. When shared
1.2778 -** cache is enabled, the [sqlite3_create_module()] API used to register
1.2779 -** virtual tables will always return an error.
1.2780 -**
1.2781 -** This routine returns [SQLITE_OK] if shared cache was
1.2782 -** enabled or disabled successfully. An [SQLITE_ERROR | error code]
1.2783 -** is returned otherwise.
1.2784 -**
1.2785 -** Shared cache is disabled by default. But this might change in
1.2786 -** future releases of SQLite. Applications that care about shared
1.2787 -** cache setting should set it explicitly.
1.2788 -*/
1.2789 -int sqlite3_enable_shared_cache(int);
1.2790 -
1.2791 -/*
1.2792 -** CAPI3REF: Attempt To Free Heap Memory
1.2793 -**
1.2794 -** Attempt to free N bytes of heap memory by deallocating non-essential
1.2795 -** memory allocations held by the database library (example: memory
1.2796 -** used to cache database pages to improve performance).
1.2797 -*/
1.2798 -int sqlite3_release_memory(int);
1.2799 -
1.2800 -/*
1.2801 -** CAPI3REF: Impose A Limit On Heap Size
1.2802 -**
1.2803 -** Place a "soft" limit on the amount of heap memory that may be allocated
1.2804 -** by SQLite. If an internal allocation is requested
1.2805 -** that would exceed the specified limit, [sqlite3_release_memory()] is
1.2806 -** invoked one or more times to free up some space before the allocation
1.2807 -** is made.
1.2808 -**
1.2809 -** The limit is called "soft", because if [sqlite3_release_memory()] cannot
1.2810 -** free sufficient memory to prevent the limit from being exceeded,
1.2811 -** the memory is allocated anyway and the current operation proceeds.
1.2812 -**
1.2813 -** A negative or zero value for N means that there is no soft heap limit and
1.2814 -** [sqlite3_release_memory()] will only be called when memory is exhausted.
1.2815 -** The default value for the soft heap limit is zero.
1.2816 -**
1.2817 -** SQLite makes a best effort to honor the soft heap limit. But if it
1.2818 -** is unable to reduce memory usage below the soft limit, execution will
1.2819 -** continue without error or notification. This is why the limit is
1.2820 -** called a "soft" limit. It is advisory only.
1.2821 -**
1.2822 -** The soft heap limit is implemented using the [sqlite3_memory_alarm()]
1.2823 -** interface. Only a single memory alarm is available in the default
1.2824 -** implementation. This means that if the application also uses the
1.2825 -** memory alarm interface it will interfere with the operation of the
1.2826 -** soft heap limit and undefined behavior will result.
1.2827 -**
1.2828 -** Prior to SQLite version 3.5.0, this routine only constrained the memory
1.2829 -** allocated by a single thread - the same thread in which this routine
1.2830 -** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
1.2831 -** applied to all threads. The value specified for the soft heap limit
1.2832 -** is an upper bound on the total memory allocation for all threads. In
1.2833 -** version 3.5.0 there is no mechanism for limiting the heap usage for
1.2834 -** individual threads.
1.2835 -*/
1.2836 -void sqlite3_soft_heap_limit(int);
1.2837 -
1.2838 -/*
1.2839 -** CAPI3REF: Extract Metadata About A Column Of A Table
1.2840 -**
1.2841 -** This routine
1.2842 -** returns meta-data about a specific column of a specific database
1.2843 -** table accessible using the connection handle passed as the first function
1.2844 -** argument.
1.2845 -**
1.2846 -** The column is identified by the second, third and fourth parameters to
1.2847 -** this function. The second parameter is either the name of the database
1.2848 -** (i.e. "main", "temp" or an attached database) containing the specified
1.2849 -** table or NULL. If it is NULL, then all attached databases are searched
1.2850 -** for the table using the same algorithm as the database engine uses to
1.2851 -** resolve unqualified table references.
1.2852 -**
1.2853 -** The third and fourth parameters to this function are the table and column
1.2854 -** name of the desired column, respectively. Neither of these parameters
1.2855 -** may be NULL.
1.2856 -**
1.2857 -** Meta information is returned by writing to the memory locations passed as
1.2858 -** the 5th and subsequent parameters to this function. Any of these
1.2859 -** arguments may be NULL, in which case the corresponding element of meta
1.2860 -** information is ommitted.
1.2861 -**
1.2862 -** <pre>
1.2863 -** Parameter Output Type Description
1.2864 -** -----------------------------------
1.2865 -**
1.2866 -** 5th const char* Data type
1.2867 -** 6th const char* Name of the default collation sequence
1.2868 -** 7th int True if the column has a NOT NULL constraint
1.2869 -** 8th int True if the column is part of the PRIMARY KEY
1.2870 -** 9th int True if the column is AUTOINCREMENT
1.2871 -** </pre>
1.2872 -**
1.2873 -**
1.2874 -** The memory pointed to by the character pointers returned for the
1.2875 -** declaration type and collation sequence is valid only until the next
1.2876 -** call to any sqlite API function.
1.2877 -**
1.2878 -** If the specified table is actually a view, then an error is returned.
1.2879 -**
1.2880 -** If the specified column is "rowid", "oid" or "_rowid_" and an
1.2881 -** INTEGER PRIMARY KEY column has been explicitly declared, then the output
1.2882 -** parameters are set for the explicitly declared column. If there is no
1.2883 -** explicitly declared IPK column, then the output parameters are set as
1.2884 -** follows:
1.2885 -**
1.2886 -** <pre>
1.2887 -** data type: "INTEGER"
1.2888 -** collation sequence: "BINARY"
1.2889 -** not null: 0
1.2890 -** primary key: 1
1.2891 -** auto increment: 0
1.2892 -** </pre>
1.2893 -**
1.2894 -** This function may load one or more schemas from database files. If an
1.2895 -** error occurs during this process, or if the requested table or column
1.2896 -** cannot be found, an SQLITE error code is returned and an error message
1.2897 -** left in the database handle (to be retrieved using sqlite3_errmsg()).
1.2898 -**
1.2899 -** This API is only available if the library was compiled with the
1.2900 -** SQLITE_ENABLE_COLUMN_METADATA preprocessor symbol defined.
1.2901 -*/
1.2902 -int sqlite3_table_column_metadata(
1.2903 - sqlite3 *db, /* Connection handle */
1.2904 - const char *zDbName, /* Database name or NULL */
1.2905 - const char *zTableName, /* Table name */
1.2906 - const char *zColumnName, /* Column name */
1.2907 - char const **pzDataType, /* OUTPUT: Declared data type */
1.2908 - char const **pzCollSeq, /* OUTPUT: Collation sequence name */
1.2909 - int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */
1.2910 - int *pPrimaryKey, /* OUTPUT: True if column part of PK */
1.2911 - int *pAutoinc /* OUTPUT: True if column is auto-increment */
1.2912 -);
1.2913 -
1.2914 -/*
1.2915 -** CAPI3REF: Load An Extension
1.2916 -**
1.2917 -** Attempt to load an SQLite extension library contained in the file
1.2918 -** zFile. The entry point is zProc. zProc may be 0 in which case the
1.2919 -** name of the entry point defaults to "sqlite3_extension_init".
1.2920 -**
1.2921 -** Return [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
1.2922 -**
1.2923 -** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with
1.2924 -** error message text. The calling function should free this memory
1.2925 -** by calling [sqlite3_free()].
1.2926 -**
1.2927 -** Extension loading must be enabled using [sqlite3_enable_load_extension()]
1.2928 -** prior to calling this API or an error will be returned.
1.2929 -*/
1.2930 -int sqlite3_load_extension(
1.2931 - sqlite3 *db, /* Load the extension into this database connection */
1.2932 - const char *zFile, /* Name of the shared library containing extension */
1.2933 - const char *zProc, /* Entry point. Derived from zFile if 0 */
1.2934 - char **pzErrMsg /* Put error message here if not 0 */
1.2935 -);
1.2936 -
1.2937 -/*
1.2938 -** CAPI3REF: Enable Or Disable Extension Loading
1.2939 -**
1.2940 -** So as not to open security holes in older applications that are
1.2941 -** unprepared to deal with extension loading, and as a means of disabling
1.2942 -** extension loading while evaluating user-entered SQL, the following
1.2943 -** API is provided to turn the [sqlite3_load_extension()] mechanism on and
1.2944 -** off. It is off by default. See ticket #1863.
1.2945 -**
1.2946 -** Call this routine with onoff==1 to turn extension loading on
1.2947 -** and call it with onoff==0 to turn it back off again.
1.2948 -*/
1.2949 -int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
1.2950 -
1.2951 -/*
1.2952 -** CAPI3REF: Make Arrangements To Automatically Load An Extension
1.2953 -**
1.2954 -** Register an extension entry point that is automatically invoked
1.2955 -** whenever a new database connection is opened using
1.2956 -** [sqlite3_open()], [sqlite3_open16()], or [sqlite3_open_v2()].
1.2957 -**
1.2958 -** This API can be invoked at program startup in order to register
1.2959 -** one or more statically linked extensions that will be available
1.2960 -** to all new database connections.
1.2961 -**
1.2962 -** Duplicate extensions are detected so calling this routine multiple
1.2963 -** times with the same extension is harmless.
1.2964 -**
1.2965 -** This routine stores a pointer to the extension in an array
1.2966 -** that is obtained from malloc(). If you run a memory leak
1.2967 -** checker on your program and it reports a leak because of this
1.2968 -** array, then invoke [sqlite3_automatic_extension_reset()] prior
1.2969 -** to shutdown to free the memory.
1.2970 -**
1.2971 -** Automatic extensions apply across all threads.
1.2972 -**
1.2973 -** This interface is experimental and is subject to change or
1.2974 -** removal in future releases of SQLite.
1.2975 -*/
1.2976 -int sqlite3_auto_extension(void *xEntryPoint);
1.2977 -
1.2978 -
1.2979 -/*
1.2980 -** CAPI3REF: Reset Automatic Extension Loading
1.2981 -**
1.2982 -** Disable all previously registered automatic extensions. This
1.2983 -** routine undoes the effect of all prior [sqlite3_automatic_extension()]
1.2984 -** calls.
1.2985 -**
1.2986 -** This call disabled automatic extensions in all threads.
1.2987 -**
1.2988 -** This interface is experimental and is subject to change or
1.2989 -** removal in future releases of SQLite.
1.2990 -*/
1.2991 -void sqlite3_reset_auto_extension(void);
1.2992 -
1.2993 -
1.2994 -/*
1.2995 -****** EXPERIMENTAL - subject to change without notice **************
1.2996 -**
1.2997 -** The interface to the virtual-table mechanism is currently considered
1.2998 -** to be experimental. The interface might change in incompatible ways.
1.2999 -** If this is a problem for you, do not use the interface at this time.
1.3000 -**
1.3001 -** When the virtual-table mechanism stablizes, we will declare the
1.3002 -** interface fixed, support it indefinitely, and remove this comment.
1.3003 -*/
1.3004 -
1.3005 -/*
1.3006 -** Structures used by the virtual table interface
1.3007 -*/
1.3008 -typedef struct sqlite3_vtab sqlite3_vtab;
1.3009 -typedef struct sqlite3_index_info sqlite3_index_info;
1.3010 -typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
1.3011 -typedef struct sqlite3_module sqlite3_module;
1.3012 -
1.3013 -/*
1.3014 -** A module is a class of virtual tables. Each module is defined
1.3015 -** by an instance of the following structure. This structure consists
1.3016 -** mostly of methods for the module.
1.3017 -*/
1.3018 -struct sqlite3_module {
1.3019 - int iVersion;
1.3020 - int (*xCreate)(sqlite3*, void *pAux,
1.3021 - int argc, const char *const*argv,
1.3022 - sqlite3_vtab **ppVTab, char**);
1.3023 - int (*xConnect)(sqlite3*, void *pAux,
1.3024 - int argc, const char *const*argv,
1.3025 - sqlite3_vtab **ppVTab, char**);
1.3026 - int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
1.3027 - int (*xDisconnect)(sqlite3_vtab *pVTab);
1.3028 - int (*xDestroy)(sqlite3_vtab *pVTab);
1.3029 - int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
1.3030 - int (*xClose)(sqlite3_vtab_cursor*);
1.3031 - int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
1.3032 - int argc, sqlite3_value **argv);
1.3033 - int (*xNext)(sqlite3_vtab_cursor*);
1.3034 - int (*xEof)(sqlite3_vtab_cursor*);
1.3035 - int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
1.3036 - int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
1.3037 - int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
1.3038 - int (*xBegin)(sqlite3_vtab *pVTab);
1.3039 - int (*xSync)(sqlite3_vtab *pVTab);
1.3040 - int (*xCommit)(sqlite3_vtab *pVTab);
1.3041 - int (*xRollback)(sqlite3_vtab *pVTab);
1.3042 - int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
1.3043 - void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
1.3044 - void **ppArg);
1.3045 -
1.3046 - int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
1.3047 -};
1.3048 -
1.3049 -/*
1.3050 -** The sqlite3_index_info structure and its substructures is used to
1.3051 -** pass information into and receive the reply from the xBestIndex
1.3052 -** method of an sqlite3_module. The fields under **Inputs** are the
1.3053 -** inputs to xBestIndex and are read-only. xBestIndex inserts its
1.3054 -** results into the **Outputs** fields.
1.3055 -**
1.3056 -** The aConstraint[] array records WHERE clause constraints of the
1.3057 -** form:
1.3058 -**
1.3059 -** column OP expr
1.3060 -**
1.3061 -** Where OP is =, <, <=, >, or >=. The particular operator is stored
1.3062 -** in aConstraint[].op. The index of the column is stored in
1.3063 -** aConstraint[].iColumn. aConstraint[].usable is TRUE if the
1.3064 -** expr on the right-hand side can be evaluated (and thus the constraint
1.3065 -** is usable) and false if it cannot.
1.3066 -**
1.3067 -** The optimizer automatically inverts terms of the form "expr OP column"
1.3068 -** and makes other simplifications to the WHERE clause in an attempt to
1.3069 -** get as many WHERE clause terms into the form shown above as possible.
1.3070 -** The aConstraint[] array only reports WHERE clause terms in the correct
1.3071 -** form that refer to the particular virtual table being queried.
1.3072 -**
1.3073 -** Information about the ORDER BY clause is stored in aOrderBy[].
1.3074 -** Each term of aOrderBy records a column of the ORDER BY clause.
1.3075 -**
1.3076 -** The xBestIndex method must fill aConstraintUsage[] with information
1.3077 -** about what parameters to pass to xFilter. If argvIndex>0 then
1.3078 -** the right-hand side of the corresponding aConstraint[] is evaluated
1.3079 -** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit
1.3080 -** is true, then the constraint is assumed to be fully handled by the
1.3081 -** virtual table and is not checked again by SQLite.
1.3082 -**
1.3083 -** The idxNum and idxPtr values are recorded and passed into xFilter.
1.3084 -** sqlite3_free() is used to free idxPtr if needToFreeIdxPtr is true.
1.3085 -**
1.3086 -** The orderByConsumed means that output from xFilter will occur in
1.3087 -** the correct order to satisfy the ORDER BY clause so that no separate
1.3088 -** sorting step is required.
1.3089 -**
1.3090 -** The estimatedCost value is an estimate of the cost of doing the
1.3091 -** particular lookup. A full scan of a table with N entries should have
1.3092 -** a cost of N. A binary search of a table of N entries should have a
1.3093 -** cost of approximately log(N).
1.3094 -*/
1.3095 -struct sqlite3_index_info {
1.3096 - /* Inputs */
1.3097 - int nConstraint; /* Number of entries in aConstraint */
1.3098 - struct sqlite3_index_constraint {
1.3099 - int iColumn; /* Column on left-hand side of constraint */
1.3100 - unsigned char op; /* Constraint operator */
1.3101 - unsigned char usable; /* True if this constraint is usable */
1.3102 - int iTermOffset; /* Used internally - xBestIndex should ignore */
1.3103 - } *aConstraint; /* Table of WHERE clause constraints */
1.3104 - int nOrderBy; /* Number of terms in the ORDER BY clause */
1.3105 - struct sqlite3_index_orderby {
1.3106 - int iColumn; /* Column number */
1.3107 - unsigned char desc; /* True for DESC. False for ASC. */
1.3108 - } *aOrderBy; /* The ORDER BY clause */
1.3109 -
1.3110 - /* Outputs */
1.3111 - struct sqlite3_index_constraint_usage {
1.3112 - int argvIndex; /* if >0, constraint is part of argv to xFilter */
1.3113 - unsigned char omit; /* Do not code a test for this constraint */
1.3114 - } *aConstraintUsage;
1.3115 - int idxNum; /* Number used to identify the index */
1.3116 - char *idxStr; /* String, possibly obtained from sqlite3_malloc */
1.3117 - int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
1.3118 - int orderByConsumed; /* True if output is already ordered */
1.3119 - double estimatedCost; /* Estimated cost of using this index */
1.3120 -};
1.3121 -#define SQLITE_INDEX_CONSTRAINT_EQ 2
1.3122 -#define SQLITE_INDEX_CONSTRAINT_GT 4
1.3123 -#define SQLITE_INDEX_CONSTRAINT_LE 8
1.3124 -#define SQLITE_INDEX_CONSTRAINT_LT 16
1.3125 -#define SQLITE_INDEX_CONSTRAINT_GE 32
1.3126 -#define SQLITE_INDEX_CONSTRAINT_MATCH 64
1.3127 -
1.3128 -/*
1.3129 -** This routine is used to register a new module name with an SQLite
1.3130 -** connection. Module names must be registered before creating new
1.3131 -** virtual tables on the module, or before using preexisting virtual
1.3132 -** tables of the module.
1.3133 -*/
1.3134 -int sqlite3_create_module(
1.3135 - sqlite3 *db, /* SQLite connection to register module with */
1.3136 - const char *zName, /* Name of the module */
1.3137 - const sqlite3_module *, /* Methods for the module */
1.3138 - void * /* Client data for xCreate/xConnect */
1.3139 -);
1.3140 -
1.3141 -/*
1.3142 -** This routine is identical to the sqlite3_create_module() method above,
1.3143 -** except that it allows a destructor function to be specified. It is
1.3144 -** even more experimental than the rest of the virtual tables API.
1.3145 -*/
1.3146 -int sqlite3_create_module_v2(
1.3147 - sqlite3 *db, /* SQLite connection to register module with */
1.3148 - const char *zName, /* Name of the module */
1.3149 - const sqlite3_module *, /* Methods for the module */
1.3150 - void *, /* Client data for xCreate/xConnect */
1.3151 - void(*xDestroy)(void*) /* Module destructor function */
1.3152 -);
1.3153 -
1.3154 -/*
1.3155 -** Every module implementation uses a subclass of the following structure
1.3156 -** to describe a particular instance of the module. Each subclass will
1.3157 -** be tailored to the specific needs of the module implementation. The
1.3158 -** purpose of this superclass is to define certain fields that are common
1.3159 -** to all module implementations.
1.3160 -**
1.3161 -** Virtual tables methods can set an error message by assigning a
1.3162 -** string obtained from sqlite3_mprintf() to zErrMsg. The method should
1.3163 -** take care that any prior string is freed by a call to sqlite3_free()
1.3164 -** prior to assigning a new string to zErrMsg. After the error message
1.3165 -** is delivered up to the client application, the string will be automatically
1.3166 -** freed by sqlite3_free() and the zErrMsg field will be zeroed. Note
1.3167 -** that sqlite3_mprintf() and sqlite3_free() are used on the zErrMsg field
1.3168 -** since virtual tables are commonly implemented in loadable extensions which
1.3169 -** do not have access to sqlite3MPrintf() or sqlite3Free().
1.3170 -*/
1.3171 -struct sqlite3_vtab {
1.3172 - const sqlite3_module *pModule; /* The module for this virtual table */
1.3173 - int nRef; /* Used internally */
1.3174 - char *zErrMsg; /* Error message from sqlite3_mprintf() */
1.3175 - /* Virtual table implementations will typically add additional fields */
1.3176 -};
1.3177 -
1.3178 -/* Every module implementation uses a subclass of the following structure
1.3179 -** to describe cursors that point into the virtual table and are used
1.3180 -** to loop through the virtual table. Cursors are created using the
1.3181 -** xOpen method of the module. Each module implementation will define
1.3182 -** the content of a cursor structure to suit its own needs.
1.3183 -**
1.3184 -** This superclass exists in order to define fields of the cursor that
1.3185 -** are common to all implementations.
1.3186 -*/
1.3187 -struct sqlite3_vtab_cursor {
1.3188 - sqlite3_vtab *pVtab; /* Virtual table of this cursor */
1.3189 - /* Virtual table implementations will typically add additional fields */
1.3190 -};
1.3191 -
1.3192 -/*
1.3193 -** The xCreate and xConnect methods of a module use the following API
1.3194 -** to declare the format (the names and datatypes of the columns) of
1.3195 -** the virtual tables they implement.
1.3196 -*/
1.3197 -int sqlite3_declare_vtab(sqlite3*, const char *zCreateTable);
1.3198 -
1.3199 -/*
1.3200 -** Virtual tables can provide alternative implementations of functions
1.3201 -** using the xFindFunction method. But global versions of those functions
1.3202 -** must exist in order to be overloaded.
1.3203 -**
1.3204 -** This API makes sure a global version of a function with a particular
1.3205 -** name and number of parameters exists. If no such function exists
1.3206 -** before this API is called, a new function is created. The implementation
1.3207 -** of the new function always causes an exception to be thrown. So
1.3208 -** the new function is not good for anything by itself. Its only
1.3209 -** purpose is to be a place-holder function that can be overloaded
1.3210 -** by virtual tables.
1.3211 -**
1.3212 -** This API should be considered part of the virtual table interface,
1.3213 -** which is experimental and subject to change.
1.3214 -*/
1.3215 -int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
1.3216 -
1.3217 -/*
1.3218 -** The interface to the virtual-table mechanism defined above (back up
1.3219 -** to a comment remarkably similar to this one) is currently considered
1.3220 -** to be experimental. The interface might change in incompatible ways.
1.3221 -** If this is a problem for you, do not use the interface at this time.
1.3222 -**
1.3223 -** When the virtual-table mechanism stabilizes, we will declare the
1.3224 -** interface fixed, support it indefinitely, and remove this comment.
1.3225 -**
1.3226 -****** EXPERIMENTAL - subject to change without notice **************
1.3227 -*/
1.3228 -
1.3229 -/*
1.3230 -** CAPI3REF: A Handle To An Open BLOB
1.3231 -**
1.3232 -** An instance of the following opaque structure is used to
1.3233 -** represent an blob-handle. A blob-handle is created by
1.3234 -** [sqlite3_blob_open()] and destroyed by [sqlite3_blob_close()].
1.3235 -** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
1.3236 -** can be used to read or write small subsections of the blob.
1.3237 -** The [sqlite3_blob_bytes()] interface returns the size of the
1.3238 -** blob in bytes.
1.3239 -*/
1.3240 -typedef struct sqlite3_blob sqlite3_blob;
1.3241 -
1.3242 -/*
1.3243 -** CAPI3REF: Open A BLOB For Incremental I/O
1.3244 -**
1.3245 -** Open a handle to the blob located in row iRow,, column zColumn,
1.3246 -** table zTable in database zDb. i.e. the same blob that would
1.3247 -** be selected by:
1.3248 -**
1.3249 -** <pre>
1.3250 -** SELECT zColumn FROM zDb.zTable WHERE rowid = iRow;
1.3251 -** </pre>
1.3252 -**
1.3253 -** If the flags parameter is non-zero, the blob is opened for
1.3254 -** read and write access. If it is zero, the blob is opened for read
1.3255 -** access.
1.3256 -**
1.3257 -** On success, [SQLITE_OK] is returned and the new
1.3258 -** [sqlite3_blob | blob handle] is written to *ppBlob.
1.3259 -** Otherwise an error code is returned and
1.3260 -** any value written to *ppBlob should not be used by the caller.
1.3261 -** This function sets the database-handle error code and message
1.3262 -** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()].
1.3263 -*/
1.3264 -int sqlite3_blob_open(
1.3265 - sqlite3*,
1.3266 - const char *zDb,
1.3267 - const char *zTable,
1.3268 - const char *zColumn,
1.3269 - sqlite3_int64 iRow,
1.3270 - int flags,
1.3271 - sqlite3_blob **ppBlob
1.3272 -);
1.3273 -
1.3274 -/*
1.3275 -** CAPI3REF: Close A BLOB Handle
1.3276 -**
1.3277 -** Close an open [sqlite3_blob | blob handle].
1.3278 -*/
1.3279 -int sqlite3_blob_close(sqlite3_blob *);
1.3280 -
1.3281 -/*
1.3282 -** CAPI3REF: Return The Size Of An Open BLOB
1.3283 -**
1.3284 -** Return the size in bytes of the blob accessible via the open
1.3285 -** [sqlite3_blob | blob-handle] passed as an argument.
1.3286 -*/
1.3287 -int sqlite3_blob_bytes(sqlite3_blob *);
1.3288 -
1.3289 -/*
1.3290 -** CAPI3REF: Read Data From A BLOB Incrementally
1.3291 -**
1.3292 -** This function is used to read data from an open
1.3293 -** [sqlite3_blob | blob-handle] into a caller supplied buffer.
1.3294 -** n bytes of data are copied into buffer
1.3295 -** z from the open blob, starting at offset iOffset.
1.3296 -**
1.3297 -** On success, SQLITE_OK is returned. Otherwise, an
1.3298 -** [SQLITE_ERROR | SQLite error code] or an
1.3299 -** [SQLITE_IOERR_READ | extended error code] is returned.
1.3300 -*/
1.3301 -int sqlite3_blob_read(sqlite3_blob *, void *z, int n, int iOffset);
1.3302 -
1.3303 -/*
1.3304 -** CAPI3REF: Write Data Into A BLOB Incrementally
1.3305 -**
1.3306 -** This function is used to write data into an open
1.3307 -** [sqlite3_blob | blob-handle] from a user supplied buffer.
1.3308 -** n bytes of data are copied from the buffer
1.3309 -** pointed to by z into the open blob, starting at offset iOffset.
1.3310 -**
1.3311 -** If the [sqlite3_blob | blob-handle] passed as the first argument
1.3312 -** was not opened for writing (the flags parameter to [sqlite3_blob_open()]
1.3313 -*** was zero), this function returns [SQLITE_READONLY].
1.3314 -**
1.3315 -** This function may only modify the contents of the blob, it is
1.3316 -** not possible to increase the size of a blob using this API. If
1.3317 -** offset iOffset is less than n bytes from the end of the blob,
1.3318 -** [SQLITE_ERROR] is returned and no data is written.
1.3319 -**
1.3320 -** On success, SQLITE_OK is returned. Otherwise, an
1.3321 -** [SQLITE_ERROR | SQLite error code] or an
1.3322 -** [SQLITE_IOERR_READ | extended error code] is returned.
1.3323 -*/
1.3324 -int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
1.3325 -
1.3326 -/*
1.3327 -** CAPI3REF: Virtual File System Objects
1.3328 -**
1.3329 -** A virtual filesystem (VFS) is an [sqlite3_vfs] object
1.3330 -** that SQLite uses to interact
1.3331 -** with the underlying operating system. Most builds come with a
1.3332 -** single default VFS that is appropriate for the host computer.
1.3333 -** New VFSes can be registered and existing VFSes can be unregistered.
1.3334 -** The following interfaces are provided.
1.3335 -**
1.3336 -** The sqlite3_vfs_find() interface returns a pointer to a VFS given its
1.3337 -** name. Names are case sensitive. If there is no match, a NULL
1.3338 -** pointer is returned. If zVfsName is NULL then the default
1.3339 -** VFS is returned.
1.3340 -**
1.3341 -** New VFSes are registered with sqlite3_vfs_register(). Each
1.3342 -** new VFS becomes the default VFS if the makeDflt flag is set.
1.3343 -** The same VFS can be registered multiple times without injury.
1.3344 -** To make an existing VFS into the default VFS, register it again
1.3345 -** with the makeDflt flag set. If two different VFSes with the
1.3346 -** same name are registered, the behavior is undefined. If a
1.3347 -** VFS is registered with a name that is NULL or an empty string,
1.3348 -** then the behavior is undefined.
1.3349 -**
1.3350 -** Unregister a VFS with the sqlite3_vfs_unregister() interface.
1.3351 -** If the default VFS is unregistered, another VFS is chosen as
1.3352 -** the default. The choice for the new VFS is arbitrary.
1.3353 -*/
1.3354 -sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
1.3355 -int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
1.3356 -int sqlite3_vfs_unregister(sqlite3_vfs*);
1.3357 -
1.3358 -/*
1.3359 -** CAPI3REF: Mutexes
1.3360 -**
1.3361 -** The SQLite core uses these routines for thread
1.3362 -** synchronization. Though they are intended for internal
1.3363 -** use by SQLite, code that links against SQLite is
1.3364 -** permitted to use any of these routines.
1.3365 -**
1.3366 -** The SQLite source code contains multiple implementations
1.3367 -** of these mutex routines. An appropriate implementation
1.3368 -** is selected automatically at compile-time. The following
1.3369 -** implementations are available in the SQLite core:
1.3370 -**
1.3371 -** <ul>
1.3372 -** <li> SQLITE_MUTEX_OS2
1.3373 -** <li> SQLITE_MUTEX_PTHREAD
1.3374 -** <li> SQLITE_MUTEX_W32
1.3375 -** <li> SQLITE_MUTEX_NOOP
1.3376 -** </ul>
1.3377 -**
1.3378 -** The SQLITE_MUTEX_NOOP implementation is a set of routines
1.3379 -** that does no real locking and is appropriate for use in
1.3380 -** a single-threaded application. The SQLITE_MUTEX_OS2,
1.3381 -** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
1.3382 -** are appropriate for use on os/2, unix, and windows.
1.3383 -**
1.3384 -** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
1.3385 -** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
1.3386 -** implementation is included with the library. The
1.3387 -** mutex interface routines defined here become external
1.3388 -** references in the SQLite library for which implementations
1.3389 -** must be provided by the application. This facility allows an
1.3390 -** application that links against SQLite to provide its own mutex
1.3391 -** implementation without having to modify the SQLite core.
1.3392 -**
1.3393 -** The sqlite3_mutex_alloc() routine allocates a new
1.3394 -** mutex and returns a pointer to it. If it returns NULL
1.3395 -** that means that a mutex could not be allocated. SQLite
1.3396 -** will unwind its stack and return an error. The argument
1.3397 -** to sqlite3_mutex_alloc() is one of these integer constants:
1.3398 -**
1.3399 -** <ul>
1.3400 -** <li> SQLITE_MUTEX_FAST
1.3401 -** <li> SQLITE_MUTEX_RECURSIVE
1.3402 -** <li> SQLITE_MUTEX_STATIC_MASTER
1.3403 -** <li> SQLITE_MUTEX_STATIC_MEM
1.3404 -** <li> SQLITE_MUTEX_STATIC_MEM2
1.3405 -** <li> SQLITE_MUTEX_STATIC_PRNG
1.3406 -** <li> SQLITE_MUTEX_STATIC_LRU
1.3407 -** </ul>
1.3408 -**
1.3409 -** The first two constants cause sqlite3_mutex_alloc() to create
1.3410 -** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
1.3411 -** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
1.3412 -** The mutex implementation does not need to make a distinction
1.3413 -** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
1.3414 -** not want to. But SQLite will only request a recursive mutex in
1.3415 -** cases where it really needs one. If a faster non-recursive mutex
1.3416 -** implementation is available on the host platform, the mutex subsystem
1.3417 -** might return such a mutex in response to SQLITE_MUTEX_FAST.
1.3418 -**
1.3419 -** The other allowed parameters to sqlite3_mutex_alloc() each return
1.3420 -** a pointer to a static preexisting mutex. Four static mutexes are
1.3421 -** used by the current version of SQLite. Future versions of SQLite
1.3422 -** may add additional static mutexes. Static mutexes are for internal
1.3423 -** use by SQLite only. Applications that use SQLite mutexes should
1.3424 -** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
1.3425 -** SQLITE_MUTEX_RECURSIVE.
1.3426 -**
1.3427 -** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
1.3428 -** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
1.3429 -** returns a different mutex on every call. But for the static
1.3430 -** mutex types, the same mutex is returned on every call that has
1.3431 -** the same type number.
1.3432 -**
1.3433 -** The sqlite3_mutex_free() routine deallocates a previously
1.3434 -** allocated dynamic mutex. SQLite is careful to deallocate every
1.3435 -** dynamic mutex that it allocates. The dynamic mutexes must not be in
1.3436 -** use when they are deallocated. Attempting to deallocate a static
1.3437 -** mutex results in undefined behavior. SQLite never deallocates
1.3438 -** a static mutex.
1.3439 -**
1.3440 -** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
1.3441 -** to enter a mutex. If another thread is already within the mutex,
1.3442 -** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
1.3443 -** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK
1.3444 -** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can
1.3445 -** be entered multiple times by the same thread. In such cases the,
1.3446 -** mutex must be exited an equal number of times before another thread
1.3447 -** can enter. If the same thread tries to enter any other kind of mutex
1.3448 -** more than once, the behavior is undefined. SQLite will never exhibit
1.3449 -** such behavior in its own use of mutexes.
1.3450 -**
1.3451 -** Some systems (ex: windows95) do not the operation implemented by
1.3452 -** sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() will
1.3453 -** always return SQLITE_BUSY. The SQLite core only ever uses
1.3454 -** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
1.3455 -**
1.3456 -** The sqlite3_mutex_leave() routine exits a mutex that was
1.3457 -** previously entered by the same thread. The behavior
1.3458 -** is undefined if the mutex is not currently entered by the
1.3459 -** calling thread or is not currently allocated. SQLite will
1.3460 -** never do either.
1.3461 -**
1.3462 -** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
1.3463 -*/
1.3464 -sqlite3_mutex *sqlite3_mutex_alloc(int);
1.3465 -void sqlite3_mutex_free(sqlite3_mutex*);
1.3466 -void sqlite3_mutex_enter(sqlite3_mutex*);
1.3467 -int sqlite3_mutex_try(sqlite3_mutex*);
1.3468 -void sqlite3_mutex_leave(sqlite3_mutex*);
1.3469 -
1.3470 -/*
1.3471 -** CAPI3REF: Mutex Verifcation Routines
1.3472 -**
1.3473 -** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
1.3474 -** are intended for use inside assert() statements. The SQLite core
1.3475 -** never uses these routines except inside an assert() and applications
1.3476 -** are advised to follow the lead of the core. The core only
1.3477 -** provides implementations for these routines when it is compiled
1.3478 -** with the SQLITE_DEBUG flag. External mutex implementations
1.3479 -** are only required to provide these routines if SQLITE_DEBUG is
1.3480 -** defined and if NDEBUG is not defined.
1.3481 -**
1.3482 -** These routines should return true if the mutex in their argument
1.3483 -** is held or not held, respectively, by the calling thread.
1.3484 -**
1.3485 -** The implementation is not required to provided versions of these
1.3486 -** routines that actually work.
1.3487 -** If the implementation does not provide working
1.3488 -** versions of these routines, it should at least provide stubs
1.3489 -** that always return true so that one does not get spurious
1.3490 -** assertion failures.
1.3491 -**
1.3492 -** If the argument to sqlite3_mutex_held() is a NULL pointer then
1.3493 -** the routine should return 1. This seems counter-intuitive since
1.3494 -** clearly the mutex cannot be held if it does not exist. But the
1.3495 -** the reason the mutex does not exist is because the build is not
1.3496 -** using mutexes. And we do not want the assert() containing the
1.3497 -** call to sqlite3_mutex_held() to fail, so a non-zero return is
1.3498 -** the appropriate thing to do. The sqlite3_mutex_notheld()
1.3499 -** interface should also return 1 when given a NULL pointer.
1.3500 -*/
1.3501 -int sqlite3_mutex_held(sqlite3_mutex*);
1.3502 -int sqlite3_mutex_notheld(sqlite3_mutex*);
1.3503 -
1.3504 -/*
1.3505 -** CAPI3REF: Mutex Types
1.3506 -**
1.3507 -** The [sqlite3_mutex_alloc()] interface takes a single argument
1.3508 -** which is one of these integer constants.
1.3509 -*/
1.3510 -#define SQLITE_MUTEX_FAST 0
1.3511 -#define SQLITE_MUTEX_RECURSIVE 1
1.3512 -#define SQLITE_MUTEX_STATIC_MASTER 2
1.3513 -#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */
1.3514 -#define SQLITE_MUTEX_STATIC_MEM2 4 /* sqlite3_release_memory() */
1.3515 -#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
1.3516 -#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
1.3517 -
1.3518 -/*
1.3519 -** CAPI3REF: Low-Level Control Of Database Files
1.3520 -**
1.3521 -** The [sqlite3_file_control()] interface makes a direct call to the
1.3522 -** xFileControl method for the [sqlite3_io_methods] object associated
1.3523 -** with a particular database identified by the second argument. The
1.3524 -** name of the database is the name assigned to the database by the
1.3525 -** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
1.3526 -** database. To control the main database file, use the name "main"
1.3527 -** or a NULL pointer. The third and fourth parameters to this routine
1.3528 -** are passed directly through to the second and third parameters of
1.3529 -** the xFileControl method. The return value of the xFileControl
1.3530 -** method becomes the return value of this routine.
1.3531 -**
1.3532 -** If the second parameter (zDbName) does not match the name of any
1.3533 -** open database file, then SQLITE_ERROR is returned. This error
1.3534 -** code is not remembered and will not be recalled by [sqlite3_errcode()]
1.3535 -** or [sqlite3_errmsg()]. The underlying xFileControl method might
1.3536 -** also return SQLITE_ERROR. There is no way to distinguish between
1.3537 -** an incorrect zDbName and an SQLITE_ERROR return from the underlying
1.3538 -** xFileControl method.
1.3539 -**
1.3540 -** See also: [SQLITE_FCNTL_LOCKSTATE]
1.3541 -*/
1.3542 -int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
1.3543 -
1.3544 -/*
1.3545 -** Undo the hack that converts floating point types to integer for
1.3546 -** builds on processors without floating point support.
1.3547 -*/
1.3548 -#ifdef SQLITE_OMIT_FLOATING_POINT
1.3549 -# undef double
1.3550 -#endif
1.3551 -
1.3552 -#ifdef __cplusplus
1.3553 -} /* End of the 'extern "C"' block */
1.3554 -#endif
1.3555 -#endif