📄 sqlite3.h
字号:
** The SQL statement text in the 2nd parameter to [sqlite3_exec()]** must remain unchanged while [sqlite3_exec()] is running.**** Requirements:** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]*/int sqlite3_exec( sqlite3*, /* An open database */ const char *sql, /* SQL to be evaluated */ int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */);/*** CAPI3REF: Result Codes {H10210} <S10700>** KEYWORDS: SQLITE_OK {error code} {error codes}** KEYWORDS: {result code} {result codes}**** Many SQLite functions return an integer result code from the set shown** here in order to indicates success or failure.**** New error codes may be added in future versions of SQLite.**** 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 /* 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 */#define SQLITE_SCHEMA 17 /* The database schema changed */#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */#define SQLITE_MISMATCH 20 /* Data type mismatch */#define SQLITE_MISUSE 21 /* Library used incorrectly */#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */#define SQLITE_AUTH 23 /* Authorization denied */#define SQLITE_FORMAT 24 /* Auxiliary database format error */#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */#define SQLITE_NOTADB 26 /* File opened that is not a database file */#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */#define SQLITE_DONE 101 /* sqlite3_step() has finished executing *//* end-of-error-codes *//*** CAPI3REF: Extended Result Codes {H10220} <S10700>** KEYWORDS: {extended error code} {extended error codes}** KEYWORDS: {extended result code} {extended result codes}**** In its default configuration, SQLite API routines return one of 26 integer** [SQLITE_OK | result codes]. However, experience has shown that many of** these result codes are too coarse-grained. They do not provide as** much information about problems as programmers might like. In an effort to** address this, newer versions of SQLite (version 3.3.8 and later) include** support for additional result codes that provide more detailed information** about errors. The extended result codes are enabled or disabled** on a per database connection basis using the** [sqlite3_extended_result_codes()] API.**** Some of the available extended result codes are listed here.** One may expect the number of extended result codes will be expand** over time. Software that uses extended result codes should expect** to see new result codes in future releases of SQLite.**** The SQLITE_OK result code will never be extended. It will always** be exactly zero.*/#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )/*** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>**** These bit values are intended for use in the** 3rd parameter to the [sqlite3_open_v2()] interface and** in the 4th parameter to the xOpen method of the** [sqlite3_vfs] object.*/#define SQLITE_OPEN_READONLY 0x00000001#define SQLITE_OPEN_READWRITE 0x00000002#define SQLITE_OPEN_CREATE 0x00000004#define SQLITE_OPEN_DELETEONCLOSE 0x00000008#define SQLITE_OPEN_EXCLUSIVE 0x00000010#define SQLITE_OPEN_MAIN_DB 0x00000100#define SQLITE_OPEN_TEMP_DB 0x00000200#define SQLITE_OPEN_TRANSIENT_DB 0x00000400#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000#define SQLITE_OPEN_SUBJOURNAL 0x00002000#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000#define SQLITE_OPEN_NOMUTEX 0x00008000#define SQLITE_OPEN_FULLMUTEX 0x00010000/*** CAPI3REF: Device Characteristics {H10240} <H11120>**** The xDeviceCapabilities method of the [sqlite3_io_methods]** object returns an integer which is a vector of the these** bit values expressing I/O characteristics of the mass storage** device that holds the file that the [sqlite3_io_methods]** refers to.**** The SQLITE_IOCAP_ATOMIC property means that all writes of** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values** mean that writes of blocks that are nnn bytes in size and** are aligned to an address which is an integer multiple of** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means** that when data is appended to a file, the data is appended** first then the size of the file is extended, never the other** way around. The SQLITE_IOCAP_SEQUENTIAL property means that** information is written to disk in the same order as calls** to xWrite().*/#define SQLITE_IOCAP_ATOMIC 0x00000001#define SQLITE_IOCAP_ATOMIC512 0x00000002#define SQLITE_IOCAP_ATOMIC1K 0x00000004#define SQLITE_IOCAP_ATOMIC2K 0x00000008#define SQLITE_IOCAP_ATOMIC4K 0x00000010#define SQLITE_IOCAP_ATOMIC8K 0x00000020#define SQLITE_IOCAP_ATOMIC16K 0x00000040#define SQLITE_IOCAP_ATOMIC32K 0x00000080#define SQLITE_IOCAP_ATOMIC64K 0x00000100#define SQLITE_IOCAP_SAFE_APPEND 0x00000200#define SQLITE_IOCAP_SEQUENTIAL 0x00000400/*** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>**** SQLite uses one of these integer values as the second** argument to calls it makes to the xLock() and xUnlock() methods** of an [sqlite3_io_methods] object.*/#define SQLITE_LOCK_NONE 0#define SQLITE_LOCK_SHARED 1#define SQLITE_LOCK_RESERVED 2#define SQLITE_LOCK_PENDING 3#define SQLITE_LOCK_EXCLUSIVE 4/*** CAPI3REF: Synchronization Type Flags {H10260} <H11120>**** When SQLite invokes the xSync() method of an** [sqlite3_io_methods] object it uses a combination of** these integer values as the second argument.**** When the SQLITE_SYNC_DATAONLY flag is used, it means that the** sync operation only needs to flush data to mass storage. Inode** information need not be flushed. If the lower four bits of the flag** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.** If the lower four bits equal SQLITE_SYNC_FULL, that means** to use Mac OS X style fullsync instead of fsync().*/#define SQLITE_SYNC_NORMAL 0x00002#define SQLITE_SYNC_FULL 0x00003#define SQLITE_SYNC_DATAONLY 0x00010/*** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>**** An [sqlite3_file] object represents an open file in the OS** interface layer. Individual OS interface implementations will** want to subclass this object by appending additional fields** for their own use. The pMethods entry is a pointer to an** [sqlite3_io_methods] object that defines methods for performing** I/O operations on the open file.*/typedef struct sqlite3_file sqlite3_file;struct sqlite3_file { const struct sqlite3_io_methods *pMethods; /* Methods for an open file */};/*** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>**** Every file opened by the [sqlite3_vfs] xOpen method populates an** [sqlite3_file] object (or, more commonly, a subclass of the** [sqlite3_file] object) with a pointer to an instance of this object.** This object defines the methods used to perform various operations** against the open file represented by the [sqlite3_file] object.**** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or** [SQLITE_SYNC_FULL]. The first choice is the normal fsync().** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY]** flag may be ORed in to indicate that only the data of the file** and not its inode needs to be synced.**** The integer values to xLock() and xUnlock() are one of** <ul>** <li> [SQLITE_LOCK_NONE],** <li> [SQLITE_LOCK_SHARED],** <li> [SQLITE_LOCK_RESERVED],** <li> [SQLITE_LOCK_PENDING], or** <li> [SQLITE_LOCK_EXCLUSIVE].** </ul>** xLock() increases the lock. xUnlock() decreases the lock.** The xCheckReservedLock() method checks whether any database connection,** either in this process or in some other process, is holding a RESERVED,** PENDING, or EXCLUSIVE lock on the file. It returns true** if such a lock exists and false otherwise.**** The xFileControl() method is a generic interface that allows custom** VFS implementations to directly control an open file using the** [sqlite3_file_control()] interface. The second "op" argument is an** integer opcode. The third argument is a generic pointer intended to** point to a structure that may contain arguments or space in which to** write return values. Potential uses for xFileControl() might be** functions to enable blocking locks with timeouts, to change the** locking strategy (for example to use dot-file locks), to inquire** about the status of a lock, or to break stale locks. The SQLite** core reserves all opcodes less than 100 for its own use.** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.** Applications that define a custom xFileControl method should use opcodes** greater than 100 to avoid conflicts.**** The xSectorSize() method returns the sector size of the** device that underlies the file. The sector size is the** minimum write that can be performed without disturbing** other bytes in the file. The xDeviceCharacteristics()** method returns a bit vector describing behaviors of the** underlying device:**** <ul>** <li> [SQLITE_IOCAP_ATOMIC]** <li> [SQLITE_IOCAP_ATOMIC512]** <li> [SQLITE_IOCAP_ATOMIC1K]** <li> [SQLITE_IOCAP_ATOMIC2K]** <li> [SQLITE_IOCAP_ATOMIC4K]** <li> [SQLITE_IOCAP_ATOMIC8K]** <li> [SQLITE_IOCAP_ATOMIC16K]** <li> [SQLITE_IOCAP_ATOMIC32K]** <li> [SQLITE_IOCAP_ATOMIC64K]** <li> [SQLITE_IOCAP_SAFE_APPEND]** <li> [SQLITE_IOCAP_SEQUENTIAL]** </ul>**** The SQLITE_IOCAP_ATOMIC property means that all writes of** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values** mean that writes of blocks that are nnn bytes in size and** are aligned to an address which is an integer multiple of** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means** that when data is appended to a file, the data is appended** first then the size of the file is extended, never the other** way around. The SQLITE_IOCAP_SEQUENTIAL property means that** information is written to disk in the same order as calls** to xWrite().**** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill** in the unread portions of the buffer with zeros. A VFS that** fails to zero-fill short reads might seem to work. However,** failure to zero-fill short reads will eventually lead to** database corruption.*/typedef struct sqlite3_io_methods sqlite3_io_methods;struct sqlite3_io_methods {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -