📄 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.278 2007/12/13 21:54:11 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 {F10010}**** {F10011} The #define in the sqlite3.h header file named** SQLITE_VERSION resolves to a string literal that identifies** the version of the SQLite library in the format "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".** {END} 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.**** {F10014} The SQLITE_VERSION_NUMBER #define resolves to an integer** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are as** with SQLITE_VERSION. {END} 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.4"#define SQLITE_VERSION_NUMBER 3005004/*** CAPI3REF: Run-Time Library Version Numbers {F10020}**** {F10021} The sqlite3_libversion_number() interface returns an integer** equal to [SQLITE_VERSION_NUMBER]. {END} The value returned** by this routine should only be different from the header values** if the application is compiled using an sqlite3.h header from a** different version of SQLite than library. Cautious programmers might** include a check in their application to verify that ** sqlite3_libversion_number() always returns the value ** [SQLITE_VERSION_NUMBER].**** {F10022} The sqlite3_version[] string constant contains the text of the** [SQLITE_VERSION] string. {F10023} The sqlite3_libversion() function returns** a pointer to the sqlite3_version[] string constant. {END} The ** sqlite3_libversion() 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 {F10100}**** {F10101} The sqlite3_threadsafe() routine returns nonzero** if SQLite was compiled with its mutexes enabled or zero if** SQLite was compiled with mutexes disabled. {END} If this** routine returns false, then it is not safe for simultaneously** running threads to both invoke SQLite interfaces.**** 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.*/int sqlite3_threadsafe(void);/*** CAPI3REF: Database Connection Handle {F12000}**** 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 {F10200}**** Because there is no cross-platform way to specify such types** SQLite includes typedefs for 64-bit signed and unsigned integers.** {F10201} The sqlite_int64 and sqlite3_int64 types specify a** 64-bit signed integer. {F10202} The sqlite_uint64 and** sqlite3_uint64 types specify a 64-bit unsigned integer. {END}**** The sqlite3_int64 and sqlite3_uint64 are the preferred type** definitions. The sqlite_int64 and sqlite_uint64 types are** supported for backwards compatibility only.*/#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 {F12010}**** {F12011} The sqlite3_close() interfaces destroys an [sqlite3] object** allocated by a prior call to [sqlite3_open()], [sqlite3_open16()], or** [sqlite3_open_v2()]. {F12012} Sqlite3_close() releases all** memory used by the connection and closes all open files. {END}.**** {F12013} If the database connection contains** [sqlite3_stmt | prepared statements] that have not been finalized** by [sqlite3_finalize()], then sqlite3_close() returns SQLITE_BUSY** and leaves the connection open. {F12014} Giving sqlite3_close()** a NULL pointer is a harmless no-op. {END}**** {U12015} Passing this routine a database connection that has already been** closed results in undefined behavior. {U12016} 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 {F12100}**** {F12101} The sqlite3_exec() interface evaluates zero or more ** UTF-8 encoded, semicolon-separated SQL statements in the zero-terminated** string of its second argument. {F12102} The SQL** statements are evaluated in the context of the database connection** specified by in the first argument.** {F12103} SQL statements are prepared one by one using** [sqlite3_prepare()] or the equivalent, evaluated** using one or more calls to [sqlite3_step()], then destroyed** using [sqlite3_finalize()]. {F12104} The return value of** sqlite3_exec() is SQLITE_OK if all SQL statement run** successfully.**** {F12105} If one or more of the SQL statements handed to** sqlite3_exec() are queries, then** the callback function specified by the 3rd parameter is** invoked once for each row of the query result. {F12106}** 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].**** {F12107} The 4th parameter to sqlite3_exec() is an arbitrary pointer** that is passed through to the callback function as its first parameter.**** {F12108} The 2nd parameter to the callback function is the number of** columns in the query result. {F12109} The 3rd parameter to the callback** is an array of pointers to strings holding the values for each column** as extracted using [sqlite3_column_text()]. NULL values in the result** set result in a NULL pointer. All other value are in their UTF-8** string representation. {F12117}** The 4th parameter to the callback is an array of strings** obtained using [sqlite3_column_name()] and holding** the names of each column, also in UTF-8.**** {F12110} 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. **** {F12112} If an error occurs while parsing or evaluating the SQL** then an appropriate error message is written into memory obtained** from [sqlite3_malloc()] and *errmsg is made to point to that message** assuming errmsg is not NULL. ** {U12113} The calling function is responsible for freeing the memory** using [sqlite3_free()].** {F12116} If [sqlite3_malloc()] fails while attempting to generate** the error message, *errmsg is set to NULL.** {F12114} If errmsg is NULL then no attempt is made to generate an** error message. <todo>Is the return code SQLITE_NOMEM or the original** error code?</todo> <todo>What happens if there are multiple errors?** Do we get code for the first error, or is the choice of reported** error arbitrary?</todo>**** {F12115} 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. {END}*/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 */);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -