📄 sqlite.h.in
字号:
** second argument is the name of the locked table and the third** argument is the number of times the table has been busy. If the** busy callback returns 0, then sqlite_exec() immediately returns** SQLITE_BUSY. If the callback returns non-zero, then sqlite_exec()** tries to open the table again and the cycle repeats.**** The default busy callback is NULL.**** Sqlite is re-entrant, so the busy handler may start a new query. ** (It is not clear why anyone would every want to do this, but it** is allowed, in theory.) 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 coredump.*/void sqlite_busy_handler(sqlite*, int(*)(void*,const char*,int), void*);/*** This routine sets a busy handler that sleeps for a while when a** table is locked. The handler will sleep multiple times until ** at least "ms" milleseconds of sleeping have been done. After** "ms" milleseconds of sleeping, the handler returns 0 which** causes sqlite_exec() to return SQLITE_BUSY.**** Calling this routine with an argument less than or equal to zero** turns off all busy handlers.*/void sqlite_busy_timeout(sqlite*, int ms);/*** This next routine is really just a wrapper around sqlite_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 sqlite_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 ** malloc() directly. Only sqlite_free_table() is able to release ** the memory properly and safely.**** The return value of this routine is the same as from sqlite_exec().*/int sqlite_get_table( sqlite*, /* 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 sqlite_get_table() allocated.*/void sqlite_free_table(char **result);/*** The following routines are wrappers around sqlite_exec() and** sqlite_get_table(). The only difference between the routines that** follow and the originals is that the second argument to the ** routines that follow is really a printf()-style format** string describing the SQL to be executed. Arguments to the format** string appear at the end of the argument list.**** 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:**** sqlite_exec_printf(db, "INSERT INTO table VALUES('%q')",** callback1, 0, 0, zText);**** 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.*/int sqlite_exec_printf( sqlite*, /* An open database */ const char *sqlFormat, /* printf-style format string for the SQL */ sqlite_callback, /* Callback function */ void *, /* 1st argument to callback function */ char **errmsg, /* Error msg written here */ ... /* Arguments to the format string. */);int sqlite_exec_vprintf( sqlite*, /* An open database */ const char *sqlFormat, /* printf-style format string for the SQL */ sqlite_callback, /* Callback function */ void *, /* 1st argument to callback function */ char **errmsg, /* Error msg written here */ va_list ap /* Arguments to the format string. */);int sqlite_get_table_printf( sqlite*, /* An open database */ const char *sqlFormat, /* printf-style format string for the SQL */ 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 */ ... /* Arguments to the format string */);int sqlite_get_table_vprintf( sqlite*, /* An open database */ const char *sqlFormat, /* printf-style format string for the SQL */ 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 */ va_list ap /* Arguments to the format string */);char *sqlite_mprintf(const char*,...);char *sqlite_vmprintf(const char*, va_list);/*** Windows systems should call this routine to free memory that** is returned in the in the errmsg parameter of sqlite_open() when** SQLite is a DLL. For some reason, it does not work to call free()** directly.*/void sqlite_freemem(void *p);/*** Windows systems need functions to call to return the sqlite_version** and sqlite_encoding strings.*/const char *sqlite_libversion(void);const char *sqlite_libencoding(void);/*** A pointer to the following structure is used to communicate with** the implementations of user-defined functions.*/typedef struct sqlite_func sqlite_func;/*** Use the following routines to create new user-defined functions. See** the documentation for details.*/int sqlite_create_function( sqlite*, /* Database where the new function is registered */ const char *zName, /* Name of the new function */ int nArg, /* Number of arguments. -1 means any number */ void (*xFunc)(sqlite_func*,int,const char**), /* C code to implement */ void *pUserData /* Available via the sqlite_user_data() call */);int sqlite_create_aggregate( sqlite*, /* Database where the new function is registered */ const char *zName, /* Name of the function */ int nArg, /* Number of arguments */ void (*xStep)(sqlite_func*,int,const char**), /* Called for each row */ void (*xFinalize)(sqlite_func*), /* Called once to get final result */ void *pUserData /* Available via the sqlite_user_data() call */);/*** Use the following routine to define the datatype returned by a** user-defined function. The second argument can be one of the** constants SQLITE_NUMERIC, SQLITE_TEXT, or SQLITE_ARGS or it** can be an integer greater than or equal to zero. The datatype** will be numeric or text (the only two types supported) if the** argument is SQLITE_NUMERIC or SQLITE_TEXT. If the argument is** SQLITE_ARGS, then the datatype is numeric if any argument to the** function is numeric and is text otherwise. If the second argument** is an integer, then the datatype of the result is the same as the** parameter to the function that corresponds to that integer.*/int sqlite_function_type( sqlite *db, /* The database there the function is registered */ const char *zName, /* Name of the function */ int datatype /* The datatype for this function */);#define SQLITE_NUMERIC (-1)#define SQLITE_TEXT (-2)#define SQLITE_ARGS (-3)/*** The user function implementations call one of the following four routines** in order to return their results. The first parameter to each of these** routines is a copy of the first argument to xFunc() or xFinialize().** The second parameter to these routines is the result to be returned.** A NULL can be passed as the second parameter to sqlite_set_result_string()** in order to return a NULL result.**** The 3rd argument to _string and _error is the number of characters to** take from the string. If this argument is negative, then all characters** up to and including the first '\000' are used.**** The sqlite_set_result_string() function allocates a buffer to hold the** result and returns a pointer to this buffer. The calling routine** (that is, the implmentation of a user function) can alter the content
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -