⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlite3.h

📁 嵌入式数据系统软件!
💻 H
📖 第 1 页 / 共 5 页
字号:
***** {F12261} This function returns the number of database rows that have been** modified by INSERT, UPDATE or DELETE statements since the database handle** was opened. {F12262} The count includes UPDATE, INSERT and DELETE ** statements executed as part of trigger programs.  {F12263} All changes** are counted as soon as the statement that makes them is completed ** (when the statement handle is passed to [sqlite3_reset()] or ** [sqlite3_finalize()]). {END}**** See also the [sqlite3_change()] interface.**** {F12265} SQLite implements the command "DELETE FROM table" without** a WHERE clause by dropping and recreating the table.  (This is much** faster than going** through and deleting individual elements form the table.)  Because of** this optimization, the change count for "DELETE FROM table" will be** zero regardless of the number of elements that were originally in the** table. To get an accurate count of the number of rows deleted, use** "DELETE FROM table WHERE 1" instead.**** {U12264} If another thread makes changes on the same database connection** while this routine is running then the return value of this routine** is undefined. {END}*/int sqlite3_total_changes(sqlite3*);/*** CAPI3REF: Interrupt A Long-Running Query {F12270}**** {F12271} This function causes any pending database operation to abort and** return at its earliest opportunity. {END} This routine is typically** called in response to a user action such as pressing "Cancel"** or Ctrl-C where the user wants a long query operation to halt** immediately.**** {F12272} It is safe to call this routine from a thread different from the** thread that is currently running the database operation. {U12273} But it** is not safe to call this routine with a database connection that** is closed or might close before sqlite3_interrupt() returns.**** If an SQL is very nearly finished at the time when sqlite3_interrupt()** is called, then it might not have an opportunity to be interrupted.** It might continue to completion.** {F12274} The SQL operation that is interrupted will return** [SQLITE_INTERRUPT].  {F12275} If the interrupted SQL operation is an** INSERT, UPDATE, or DELETE that is inside an explicit transaction, ** then the entire transaction will be rolled back automatically.** {F12276} A call to sqlite3_interrupt() has no effect on SQL statements** that are started after sqlite3_interrupt() returns.*/void sqlite3_interrupt(sqlite3*);/*** CAPI3REF: Determine If An SQL Statement Is Complete {F10510}**** These routines are useful for command-line input to determine if the** currently entered text seems to form complete a SQL statement or** if additional input is needed before sending the text into** SQLite for parsing.  These routines return true if the input string** appears to be a complete SQL statement.  A statement is judged to be** complete if it ends with a semicolon and is not a fragment of a** CREATE TRIGGER statement.  These routines do not parse the SQL and** so will not detect syntactically incorrect SQL.**** {F10511} These functions return true if the given input string ** ends with a semicolon optionally followed by whitespace or** comments. {F10512} For sqlite3_complete(),** the parameter must be a zero-terminated UTF-8 string. {F10513} For** sqlite3_complete16(), a zero-terminated machine byte order UTF-16 string** is required.  {F10514} These routines return false if the terminal** semicolon is within a comment, a string literal or a quoted identifier** (in other words if the final semicolon is not really a separate token** but part of a larger token) or if the final semicolon is** in between the BEGIN and END keywords of a CREATE TRIGGER statement.** {END}*/int sqlite3_complete(const char *sql);int sqlite3_complete16(const void *sql);/*** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {F12310}**** {F12311} This routine identifies a callback function that might be** invoked whenever an attempt is made to open a database table ** that another thread or process has locked.** {F12312} If the busy callback is NULL, then [SQLITE_BUSY]** or [SQLITE_IOERR_BLOCKED]** is returned immediately upon encountering the lock.** {F12313} If the busy callback is not NULL, then the** callback will be invoked with two arguments.  {F12314} The** first argument to the handler is a copy of the void* pointer which** is the third argument to this routine.  {F12315} The second argument to** the handler is the number of times that the busy handler has** been invoked for this locking event.  {F12316} If the** busy callback returns 0, then no additional attempts are made to** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.** {F12317} If the callback returns non-zero, then another attempt** is made to open the database for reading and the cycle repeats.**** The presence of a busy handler does not guarantee that** it will be invoked when there is lock contention. {F12319}** If SQLite determines that invoking the busy handler could result in** a deadlock, it will go ahead and return [SQLITE_BUSY] or** [SQLITE_IOERR_BLOCKED] instead of invoking the** busy handler. {END}** Consider a scenario where one process is holding a read lock that** it is trying to promote to a reserved lock and** a second process is holding a reserved lock that it is trying** to promote to an exclusive lock.  The first process cannot proceed** because it is blocked by the second and the second process cannot** proceed because it is blocked by the first.  If both processes** invoke the busy handlers, neither will make any progress.  Therefore,** SQLite returns [SQLITE_BUSY] for the first process, hoping that this** will induce the first process to release its read lock and allow** the second process to proceed.**** {F12321} The default busy callback is NULL. {END}**** {F12322} The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]** when SQLite is in the middle of a large transaction where all the** changes will not fit into the in-memory cache.  {F12323} SQLite will** already hold a RESERVED lock on the database file, but it needs** to promote this lock to EXCLUSIVE so that it can spill cache** pages into the database file without harm to concurrent** readers.  {F12324} If it is unable to promote the lock, then the in-memory** cache will be left in an inconsistent state and so the error** code is promoted from the relatively benign [SQLITE_BUSY] to** the more severe [SQLITE_IOERR_BLOCKED].  {F12325} This error code promotion** forces an automatic rollback of the changes. {END} See the** <a href="http://www.sqlite.org/cvstrac/wiki?p=CorruptionFollowingBusyError">** CorruptionFollowingBusyError</a> wiki page for a discussion of why** this is important.**	** {F12326} Sqlite is re-entrant, so the busy handler may start a new** query. {END} (It is not clear why anyone would every want to do this,** but it is allowed, in theory.) {U12327} But the busy handler may not** close the database.  Closing the database from a busy handler will delete ** data structures out from under the executing query and will ** probably result in a segmentation fault or other runtime error. {END}**** {F12328} There can only be a single busy handler defined for each database** connection.  Setting a new busy handler clears any previous one. ** {F12329} Note that calling [sqlite3_busy_timeout()] will also set or clear** the busy handler.**** {F12331} When operating in [sqlite3_enable_shared_cache | shared cache mode],** only a single busy handler can be defined for each database file.** So if two database connections share a single cache, then changing** the busy handler on one connection will also change the busy** handler in the other connection.  {F12332} The busy handler is invoked** in the thread that was running when the lock contention occurs.*/int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);/*** CAPI3REF: Set A Busy Timeout {F12340}**** {F12341} This routine sets a [sqlite3_busy_handler | busy handler]** that sleeps for a while when a** table is locked.  {F12342} The handler will sleep multiple times until ** at least "ms" milliseconds of sleeping have been done. {F12343} After** "ms" milliseconds of sleeping, the handler returns 0 which** causes [sqlite3_step()] to return [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].**** {F12344} Calling this routine with an argument less than or equal to zero** turns off all busy handlers.**** {F12345} There can only be a single busy handler for a particular database** connection.  If another busy handler was defined  ** (using [sqlite3_busy_handler()]) prior to calling** this routine, that other busy handler is cleared.*/int sqlite3_busy_timeout(sqlite3*, int ms);/*** CAPI3REF: Convenience Routines For Running Queries {F12370}**** This next routine is a convenience wrapper around [sqlite3_exec()].** {F12371} 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 [sqlite3_malloc()], then returns all of the result after the** query has finished. {F12372}**** As an example, suppose the query result where this table:**** <blockquote><pre>**        Name        | Age**        -----------------------**        Alice       | 43**        Bob         | 28**        Cindy       | 21** </pre></blockquote>**** If the 3rd argument were &azResult then after the function returns** azResult will contain the following data:**** <blockquote><pre>**        azResult&#91;0] = "Name";**        azResult&#91;1] = "Age";**        azResult&#91;2] = "Alice";**        azResult&#91;3] = "43";**        azResult&#91;4] = "Bob";**        azResult&#91;5] = "28";**        azResult&#91;6] = "Cindy";**        azResult&#91;7] = "21";** </pre></blockquote>**** 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).**** {U12374} 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 ** [sqlite3_malloc()] happens, the calling function must not try to call ** [sqlite3_free()] directly.  Only [sqlite3_free_table()] is able to release ** the memory properly and safely. {END}**** {F12373} 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 */);void sqlite3_free_table(char **result);/*** CAPI3REF: Formatted String Printing Functions {F17400}**** These routines are workalikes of the "printf()" family of functions** from the standard C library.**** {F17401} The sqlite3_mprintf() and sqlite3_vmprintf() routines write their** results into memory obtained from [sqlite3_malloc()].** {U17402} The strings returned by these two routines should be** released by [sqlite3_free()]. {F17403}  Both routines return a** NULL pointer if [sqlite3_malloc()] is unable to allocate enough** memory to hold the resulting string.**** {F17404} In sqlite3_snprintf() routine is similar to "snprintf()" from** the standard C library.  The result is written into the** buffer supplied as the second parameter whose size is given by** the first parameter. {END} Note that the order of the** first two parameters is reversed from snprintf().  This is an** historical accident that cannot be fixed without breaking** backwards compatibility.  {F17405} Note also that sqlite3_snprintf()** returns a pointer to its buffer instead of the number of** characters actually written into the buffer. {END} We admit that** the number of characters written would be a more useful return** value but we cannot change the implementation of sqlite3_snprintf()** now without breaking compatibility.**** {F17406} As long as the buffer size is greater than zero, sqlite3_snprintf()** guarantees that the buffer is always zero-terminated. {F17407} The first** parameter "n" is the total size of the buffer, including space for** the zero terminator.  {END} So the longest string that can be completely** written will be n-1 characters.**** These routines all implement some additional formatting** options that are useful for constructing SQL statements.** All of the usual printf formatting options apply.  In addition, there** is are "%q", "%Q", and "%z" options.**** {F17410} The %q option 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. {END} 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:**** <blockquote><pre>**  char *zText = "It's a happy day!";** </pre></blockquote>**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -