📄 sqlite3.h
字号:
/*** 2001 September 15**** The author disclaims copyright to this source code. In place of** a legal notice, here is a blessing:**** May you do good and not evil.** May you find forgiveness for yourself and forgive others.** May you share freely, never taking more than you give.***************************************************************************** This header file defines the interface that the SQLite library** presents to client programs. If a C-function, structure, datatype,** or constant definition does not appear in this file, then it is** not a published API of SQLite, is subject to change without** notice, and should not be referenced by programs that use SQLite.**** Some of the definitions that are in this file are marked as** "experimental". Experimental interfaces are normally new** features recently added to SQLite. We do not anticipate changes ** to experimental interfaces but reserve to make minor changes if** experience from use "in the wild" suggest such changes are prudent.**** The official C-language API documentation for SQLite is derived** from comments in this file. This file is the authoritative source** on how SQLite interfaces are suppose to operate.**** The name of this file under configuration management is "sqlite.h.in".** The makefile makes some minor changes to this file (such as inserting** the version number) and changes its name to "sqlite3.h" as** part of the build process.**** @(#) $Id: sqlite.h.in,v 1.256 2007/09/03 20:32:45 drh Exp $*/#ifndef _SQLITE3_H_#define _SQLITE3_H_#include <stdarg.h> /* Needed for the definition of va_list *//*** Make sure we can call this stuff from C++.*/#ifdef __cplusplusextern "C" {#endif/*** Add the ability to override 'extern'*/#ifndef SQLITE_EXTERN# define SQLITE_EXTERN extern#endif/*** Make sure these symbols where not defined by some previous header** file.*/#ifdef SQLITE_VERSION# undef SQLITE_VERSION#endif#ifdef SQLITE_VERSION_NUMBER# undef SQLITE_VERSION_NUMBER#endif/*** CAPI3REF: Compile-Time Library Version Numbers**** The version of the SQLite library is contained in the sqlite3.h** header file in a #define named SQLITE_VERSION. The SQLITE_VERSION** macro resolves to a string constant.**** The format of the version string is "X.Y.Z", where** X is the major version number, Y is the minor version number and Z** is the release number. The X.Y.Z might be followed by "alpha" or "beta".** For example "3.1.1beta".**** The X value is always 3 in SQLite. The X value only changes when** backwards compatibility is broken and we intend to never break** backwards compatibility. The Y value only changes when** there are major feature enhancements that are forwards compatible** but not backwards compatible. The Z value is incremented with** each release but resets back to 0 when Y is incremented.**** The SQLITE_VERSION_NUMBER is an integer with the value ** (X*1000000 + Y*1000 + Z). For example, for version "3.1.1beta", ** SQLITE_VERSION_NUMBER is set to 3001001. To detect if they are using ** version 3.1.1 or greater at compile time, programs may use the test ** (SQLITE_VERSION_NUMBER>=3001001).**** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()].*/#define SQLITE_VERSION "3.5.0"#define SQLITE_VERSION_NUMBER 3005000/*** CAPI3REF: Run-Time Library Version Numbers**** These routines return values equivalent to the header constants** [SQLITE_VERSION] and [SQLITE_VERSION_NUMBER]. The values returned** by this routines should only be different from the header values** if you compile your program using an sqlite3.h header from a** different version of SQLite that the version of the library you** link against.**** The sqlite3_version[] string constant contains the text of the** [SQLITE_VERSION] string. The sqlite3_libversion() function returns** a poiner to the sqlite3_version[] string constant. The function** is provided for DLL users who can only access functions and not** constants within the DLL.*/SQLITE_EXTERN const char sqlite3_version[];const char *sqlite3_libversion(void);int sqlite3_libversion_number(void);/*** CAPI3REF: Test To See If The Library Is Threadsafe**** This routine returns TRUE (nonzero) if SQLite was compiled with** all of its mutexes enabled and is thus threadsafe. It returns** zero if the particular build is for single-threaded operation** only.**** Really all this routine does is return true if SQLite was compiled** with the -DSQLITE_THREADSAFE=1 option and false if** compiled with -DSQLITE_THREADSAFE=0. If SQLite uses an** application-defined mutex subsystem, malloc subsystem, collating** sequence, VFS, SQL function, progress callback, commit hook,** extension, or other accessories and these add-ons are not** threadsafe, then clearly the combination will not be threadsafe** either. Hence, this routine never reports that the library** is guaranteed to be threadsafe, only when it is guaranteed not** to be.**** This is an experimental API and may go away or change in future** releases.*/int sqlite3_threadsafe(void);/*** CAPI3REF: Database Connection Handle**** Each open SQLite database is represented by pointer to an instance of the** opaque structure named "sqlite3". It is useful to think of an sqlite3** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and** [sqlite3_open_v2()] interfaces are its constructors** and [sqlite3_close()] is its destructor. There are many other interfaces** (such as [sqlite3_prepare_v2()], [sqlite3_create_function()], and** [sqlite3_busy_timeout()] to name but three) that are methods on this** object.*/typedef struct sqlite3 sqlite3;/*** CAPI3REF: 64-Bit Integer Types**** Some compilers do not support the "long long" datatype. So we have** to do compiler-specific typedefs for 64-bit signed and unsigned integers.**** Many SQLite interface functions require a 64-bit integer arguments.** Those interfaces are declared using this typedef.*/#ifdef SQLITE_INT64_TYPE typedef SQLITE_INT64_TYPE sqlite_int64; typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;#elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; typedef unsigned __int64 sqlite_uint64;#else typedef long long int sqlite_int64; typedef unsigned long long int sqlite_uint64;#endiftypedef sqlite_int64 sqlite3_int64;typedef sqlite_uint64 sqlite3_uint64;/*** If compiling for a processor that lacks floating point support,** substitute integer for floating-point*/#ifdef SQLITE_OMIT_FLOATING_POINT# define double sqlite3_int64#endif/*** CAPI3REF: Closing A Database Connection**** Call this function with a pointer to a structure that was previously** returned from [sqlite3_open()], [sqlite3_open16()], or** [sqlite3_open_v2()] and the corresponding database will by** closed.**** All SQL statements prepared using [sqlite3_prepare_v2()] or** [sqlite3_prepare16_v2()] must be destroyed using [sqlite3_finalize()]** before this routine is called. Otherwise, SQLITE_BUSY is returned and the** database connection remains open.**** Passing this routine a database connection that has already been** closed results in undefined behavior. If other interfaces that** reference the same database connection are pending (either in the** same thread or in different threads) when this routine is called,** then the behavior is undefined and is almost certainly undesirable.*/int sqlite3_close(sqlite3 *);/*** The type for a callback function.** This is legacy and deprecated. It is included for historical** compatibility and is not documented.*/typedef int (*sqlite3_callback)(void*,int,char**, char**);/*** CAPI3REF: One-Step Query Execution Interface**** This interface is used to do a one-time evaluatation of zero** or more SQL statements. UTF-8 text of the SQL statements to** be evaluted is passed in as the second parameter. The statements** are prepared one by one using [sqlite3_prepare()], evaluated** using [sqlite3_step()], then destroyed using [sqlite3_finalize()].**** If one or more of the SQL statements are queries, then** the callback function specified by the 3rd parameter is** invoked once for each row of the query result. This callback** should normally return 0. If the callback returns a non-zero** value then the query is aborted, all subsequent SQL statements** are skipped and the sqlite3_exec() function returns the [SQLITE_ABORT].**** The 4th parameter to this interface is an arbitrary pointer that is** passed through to the callback function as its first parameter.**** The 2nd parameter to the callback function is the number of** columns in the query result. The 3rd parameter to the callback** is an array of strings holding the values for each column** as extracted using [sqlite3_column_text()].** The 4th parameter to the callback is an array of strings** obtained using [sqlite3_column_name()] and holding** the names of each column.**** The callback function may be NULL, even for queries. A NULL** callback is not an error. It just means that no callback** will be invoked.**** If an error occurs while parsing or evaluating the SQL (but** not while executing the callback) then an appropriate error** message is written into memory obtained from [sqlite3_malloc()] and** *errmsg is made to point to that message. The calling function** is responsible for freeing the memory using [sqlite3_free()].** If errmsg==NULL, then no error message is ever written.**** The return value is is SQLITE_OK if there are no errors and** some other [SQLITE_OK | return code] if there is an error. ** The particular return value depends on the type of error. ***/int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluted */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */);/*** CAPI3REF: Result Codes** KEYWORDS: SQLITE_OK**** Many SQLite functions return an integer result code from the set shown** above in order to indicates success or failure.**** The result codes above are the only ones returned by SQLite in its** default configuration. However, the [sqlite3_extended_result_codes()]** API can be used to set a database connectoin to return more detailed** result codes.**** See also: [SQLITE_IOERR_READ | extended result codes]***/#define SQLITE_OK 0 /* Successful result *//* beginning-of-error-codes */#define SQLITE_ERROR 1 /* SQL error or missing database */#define SQLITE_INTERNAL 2 /* NOT USED. Internal logic error in SQLite */#define SQLITE_PERM 3 /* Access permission denied */#define SQLITE_ABORT 4 /* Callback routine requested an abort */#define SQLITE_BUSY 5 /* The database file is locked */#define SQLITE_LOCKED 6 /* A table in the database is locked */#define SQLITE_NOMEM 7 /* A malloc() failed */#define SQLITE_READONLY 8 /* Attempt to write a readonly database */#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */#define SQLITE_CORRUPT 11 /* The database disk image is malformed */#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */#define SQLITE_FULL 13 /* Insertion failed because database is full */#define SQLITE_CANTOPEN 14 /* Unable to open the database file */#define SQLITE_PROTOCOL 15 /* NOT USED. Database lock protocol error */#define SQLITE_EMPTY 16 /* Database is empty */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -