📄 sqlite3.h
字号:
**** Calling this routine with an argument less than or equal to zero** turns off all busy handlers.*/int sqlite3_busy_timeout(sqlite3*, int ms);/*** This next routine is really just a wrapper around sqlite3_exec().** Instead of invoking a user-supplied callback for each row of the** result, this routine remembers each row of the result in memory** obtained from malloc(), then returns all of the result after the** query has finished. **** As an example, suppose the query result where this table:**** Name | Age** -----------------------** Alice | 43** Bob | 28** Cindy | 21**** If the 3rd argument were &azResult then after the function returns** azResult will contain the following data:**** azResult[0] = "Name";** azResult[1] = "Age";** azResult[2] = "Alice";** azResult[3] = "43";** azResult[4] = "Bob";** azResult[5] = "28";** azResult[6] = "Cindy";** azResult[7] = "21";**** Notice that there is an extra row of data containing the column** headers. But the *nrow return value is still 3. *ncolumn is** set to 2. In general, the number of values inserted into azResult** will be ((*nrow) + 1)*(*ncolumn).**** After the calling function has finished using the result, it should ** pass the result data pointer to sqlite3_free_table() in order to ** release the memory that was malloc-ed. Because of the way the ** malloc() happens, the calling function must not try to call ** free() directly. Only sqlite3_free_table() is able to release ** the memory properly and safely.**** The return value of this routine is the same as from sqlite3_exec().*/int sqlite3_get_table( sqlite3*, /* An open database */ const char *sql, /* SQL to be executed */ char ***resultp, /* Result written to a char *[] that this points to */ int *nrow, /* Number of result rows written here */ int *ncolumn, /* Number of result columns written here */ char **errmsg /* Error msg written here */);/*** Call this routine to free the memory that sqlite3_get_table() allocated.*/void sqlite3_free_table(char **result);/*** The following routines are variants of the "sprintf()" from the** standard C library. The resulting string is written into memory** obtained from malloc() so that there is never a possiblity of buffer** overflow. These routines also implement some additional formatting** options that are useful for constructing SQL statements.**** The strings returned by these routines should be freed by calling** sqlite3_free().**** All of the usual printf formatting options apply. In addition, there** is a "%q" option. %q works like %s in that it substitutes a null-terminated** string from the argument list. But %q also doubles every '\'' character.** %q is designed for use inside a string literal. By doubling each '\''** character it escapes that character and allows it to be inserted into** the string.**** For example, so some string variable contains text as follows:**** char *zText = "It's a happy day!";**** We can use this text in an SQL statement as follows:**** char *z = sqlite3_mprintf("INSERT INTO TABLES('%q')", zText);** sqlite3_exec(db, z, callback1, 0, 0);** sqlite3_free(z);**** Because the %q format string is used, the '\'' character in zText** is escaped and the SQL generated is as follows:**** INSERT INTO table1 VALUES('It''s a happy day!')**** This is correct. Had we used %s instead of %q, the generated SQL** would have looked like this:**** INSERT INTO table1 VALUES('It's a happy day!');**** This second example is an SQL syntax error. As a general rule you** should always use %q instead of %s when inserting text into a string ** literal.*/char *sqlite3_mprintf(const char*,...);char *sqlite3_vmprintf(const char*, va_list);char *sqlite3_snprintf(int,char*,const char*, ...);/*** SQLite uses its own memory allocator. On many installations, this** memory allocator is identical to the standard malloc()/realloc()/free()** and can be used interchangable. On others, the implementations are** different. For maximum portability, it is best not to mix calls** to the standard malloc/realloc/free with the sqlite versions.*/void *sqlite3_malloc(int);void *sqlite3_realloc(void*, int);void sqlite3_free(void*);#ifndef SQLITE_OMIT_AUTHORIZATION/*** This routine registers a callback with the SQLite library. The** callback is invoked (at compile-time, not at run-time) for each** attempt to access a column of a table in the database. The callback** returns SQLITE_OK if access is allowed, SQLITE_DENY if the entire** SQL statement should be aborted with an error and SQLITE_IGNORE** if the column should be treated as a NULL value.*/int sqlite3_set_authorizer( sqlite3*, int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), void *pUserData);#endif/*** The second parameter to the access authorization function above will** be one of the values below. These values signify what kind of operation** is to be authorized. The 3rd and 4th parameters to the authorization** function will be parameters or NULL depending on which of the following** codes is used as the second parameter. The 5th parameter is the name** of the database ("main", "temp", etc.) if applicable. The 6th parameter** is the name of the inner-most trigger or view that is responsible for** the access attempt or NULL if this access attempt is directly from ** input SQL code.**** Arg-3 Arg-4*/#define SQLITE_COPY 0 /* Table Name File Name */#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */#define SQLITE_CREATE_VIEW 8 /* View Name NULL */#define SQLITE_DELETE 9 /* Table Name NULL */#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */#define SQLITE_DROP_TABLE 11 /* Table Name NULL */#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */#define SQLITE_DROP_VIEW 17 /* View Name NULL */#define SQLITE_INSERT 18 /* Table Name NULL */#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */#define SQLITE_READ 20 /* Table Name Column Name */#define SQLITE_SELECT 21 /* NULL NULL */#define SQLITE_TRANSACTION 22 /* NULL NULL */#define SQLITE_UPDATE 23 /* Table Name Column Name */#define SQLITE_ATTACH 24 /* Filename NULL */#define SQLITE_DETACH 25 /* Database Name NULL */#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */#define SQLITE_REINDEX 27 /* Index Name NULL */#define SQLITE_ANALYZE 28 /* Table Name NULL */#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name *//*** The return value of the authorization function should be one of the** following constants:*//* #define SQLITE_OK 0 // Allow access (This is actually defined above) */#define SQLITE_DENY 1 /* Abort the SQL statement with an error */#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error *//*** Register a function for tracing SQL command evaluation. The function** registered by sqlite3_trace() is invoked at the first sqlite3_step()** for the evaluation of an SQL statement. The function registered by** sqlite3_profile() runs at the end of each SQL statement and includes** information on how long that statement ran.**** The sqlite3_profile() API is currently considered experimental and** is subject to change.*/void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);void *sqlite3_profile(sqlite3*, void(*xProfile)(void*,const char*,sqlite_uint64), void*);/*** This routine configures a callback function - the progress callback - that** is invoked periodically during long running calls to sqlite3_exec(),** sqlite3_step() and sqlite3_get_table(). An example use for this API is to ** keep a GUI updated during a large query.**** The progress callback is invoked once for every N virtual machine opcodes,** where N is the second argument to this function. The progress callback** itself is identified by the third argument to this function. The fourth** argument to this function is a void pointer passed to the progress callback** function each time it is invoked.**** If a call to sqlite3_exec(), sqlite3_step() or sqlite3_get_table() results ** in less than N opcodes being executed, then the progress callback is not** invoked.** ** To remove the progress callback altogether, pass NULL as the third** argument to this function.**** If the progress callback returns a result other than 0, then the current ** query is immediately terminated and any database changes rolled back. If the** query was part of a larger transaction, then the transaction is not rolled** back and remains active. The sqlite3_exec() call returns SQLITE_ABORT. ********* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE *******/void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);/*** Register a callback function to be invoked whenever a new transaction** is committed. The pArg argument is passed through to the callback.** callback. If the callback function returns non-zero, then the commit** is converted into a rollback.**** If another function was previously registered, its pArg value is returned.** Otherwise NULL is returned.**** Registering a NULL function disables the callback.********* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE *******/void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);/*** Open the sqlite database file "filename". The "filename" is UTF-8** encoded for sqlite3_open() and UTF-16 encoded in the native byte order** for sqlite3_open16(). An sqlite3* handle is returned in *ppDb, even** if an error occurs. If the database is opened (or created) successfully,** then SQLITE_OK is returned. Otherwise an error code is returned. The** sqlite3_errmsg() or sqlite3_errmsg16() routines can be used to obtain** an English language description of the error.**** If the database file does not exist, then a new database is created.** The encoding for the database is UTF-8 if sqlite3_open() is called and** UTF-16 if sqlite3_open16 is used.**** Whether or not an error occurs when it is opened, resources associated** with the sqlite3* handle should be released by passing it to** sqlite3_close() when it is no longer required.*/int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */);int sqlite3_open16( const void *filename, /* Database filename (UTF-16) */ sqlite3 **ppDb /* OUT: SQLite db handle */);/*** Return the error code for the most recent sqlite3_* API call associated** with sqlite3 handle 'db'. SQLITE_OK is returned if the most recent ** API call was successful.**** Calls to many sqlite3_* functions set the error code and string returned** by sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16()** (overwriting the previous values). Note that calls to sqlite3_errcode(),** sqlite3_errmsg() and sqlite3_errmsg16() themselves do not affect the** results of future invocations.**** Assuming no other intervening sqlite3_* API calls are made, the error** code returned by this function is associated with the same error as** the strings returned by sqlite3_errmsg() and sqlite3_errmsg16().*/int sqlite3_errcode(sqlite3 *db);/*** Return a pointer to a UTF-8 encoded string describing in english the** error condition for the most recent sqlite3_* API call. The returned** string is always terminated by an 0x00 byte.**** The string "not an error" is returned when the most recent API call was** successful.*/const char *sqlite3_errmsg(sqlite3*);/*** Return a pointer to a UTF-16 native byte order encoded string describing** in english the error condition for the most recent sqlite3_* API call.** The returned string is always terminated by a pair of 0x00 bytes.**** The string "not an error" is returned when the most recent API call was** successful.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -