📄 sqlite3.h
字号:
** The following access routines are provided:**** _type() Return the datatype of the result. This is one of** SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, SQLITE_BLOB,** or SQLITE_NULL.** _blob() Return the value of a BLOB.** _bytes() Return the number of bytes in a BLOB value or the number** of bytes in a TEXT value represented as UTF-8. The \000** terminator is included in the byte count for TEXT values.** _bytes16() Return the number of bytes in a BLOB value or the number** of bytes in a TEXT value represented as UTF-16. The \u0000** terminator is included in the byte count for TEXT values.** _double() Return a FLOAT value.** _int() Return an INTEGER value in the host computer's native** integer representation. This might be either a 32- or 64-bit** integer depending on the host.** _int64() Return an INTEGER value as a 64-bit signed integer.** _text() Return the value as UTF-8 text.** _text16() Return the value as UTF-16 text.*/const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);int sqlite3_column_bytes(sqlite3_stmt*, int iCol);int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);double sqlite3_column_double(sqlite3_stmt*, int iCol);int sqlite3_column_int(sqlite3_stmt*, int iCol);sqlite_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);int sqlite3_column_type(sqlite3_stmt*, int iCol);int sqlite3_column_numeric_type(sqlite3_stmt*, int iCol);sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);/*** The sqlite3_finalize() function is called to delete a compiled** SQL statement obtained by a previous call to sqlite3_prepare()** or sqlite3_prepare16(). If the statement was executed successfully, or** not executed at all, then SQLITE_OK is returned. If execution of the** statement failed then an error code is returned. **** This routine can be called at any point during the execution of the** virtual machine. If the virtual machine has not completed execution** when this routine is called, that is like encountering an error or** an interrupt. (See sqlite3_interrupt().) Incomplete updates may be** rolled back and transactions cancelled, depending on the circumstances,** and the result code returned will be SQLITE_ABORT.*/int sqlite3_finalize(sqlite3_stmt *pStmt);/*** The sqlite3_reset() function is called to reset a compiled SQL** statement obtained by a previous call to sqlite3_prepare() or** sqlite3_prepare16() back to it's initial state, ready to be re-executed.** Any SQL statement variables that had values bound to them using** the sqlite3_bind_*() API retain their values.*/int sqlite3_reset(sqlite3_stmt *pStmt);/*** The following two functions are used to add user functions or aggregates** implemented in C to the SQL langauge interpreted by SQLite. The** difference only between the two is that the second parameter, the** name of the (scalar) function or aggregate, is encoded in UTF-8 for** sqlite3_create_function() and UTF-16 for sqlite3_create_function16().**** The first argument is the database handle that the new function or** aggregate is to be added to. If a single program uses more than one** database handle internally, then user functions or aggregates must ** be added individually to each database handle with which they will be** used.**** The third parameter is the number of arguments that the function or** aggregate takes. If this parameter is negative, then the function or** aggregate may take any number of arguments.**** The fourth parameter is one of SQLITE_UTF* values defined below,** indicating the encoding that the function is most likely to handle** values in. This does not change the behaviour of the programming** interface. However, if two versions of the same function are registered** with different encoding values, SQLite invokes the version likely to** minimize conversions between text encodings.**** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are** pointers to user implemented C functions that implement the user** function or aggregate. A scalar function requires an implementation of** the xFunc callback only, NULL pointers should be passed as the xStep** and xFinal parameters. An aggregate function requires an implementation** of xStep and xFinal, but NULL should be passed for xFunc. To delete an** existing user function or aggregate, pass NULL for all three function** callback. Specifying an inconstent set of callback values, such as an** xFunc and an xFinal, or an xStep but no xFinal, SQLITE_ERROR is** returned.*/int sqlite3_create_function( sqlite3 *, const char *zFunctionName, int nArg, int eTextRep, void*, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*));int sqlite3_create_function16( sqlite3*, const void *zFunctionName, int nArg, int eTextRep, void*, void (*xFunc)(sqlite3_context*,int,sqlite3_value**), void (*xStep)(sqlite3_context*,int,sqlite3_value**), void (*xFinal)(sqlite3_context*));/*** This function is deprecated. Do not use it. It continues to exist** so as not to break legacy code. But new code should avoid using it.*/int sqlite3_aggregate_count(sqlite3_context*);/*** The next group of routines returns information about parameters to** a user-defined function. Function implementations use these routines** to access their parameters. These routines are the same as the** sqlite3_column_* routines except that these routines take a single** sqlite3_value* pointer instead of an sqlite3_stmt* and an integer** column number.*/const void *sqlite3_value_blob(sqlite3_value*);int sqlite3_value_bytes(sqlite3_value*);int sqlite3_value_bytes16(sqlite3_value*);double sqlite3_value_double(sqlite3_value*);int sqlite3_value_int(sqlite3_value*);sqlite_int64 sqlite3_value_int64(sqlite3_value*);const unsigned char *sqlite3_value_text(sqlite3_value*);const void *sqlite3_value_text16(sqlite3_value*);const void *sqlite3_value_text16le(sqlite3_value*);const void *sqlite3_value_text16be(sqlite3_value*);int sqlite3_value_type(sqlite3_value*);int sqlite3_value_numeric_type(sqlite3_value*);/*** Aggregate functions use the following routine to allocate** a structure for storing their state. The first time this routine** is called for a particular aggregate, a new structure of size nBytes** is allocated, zeroed, and returned. On subsequent calls (for the** same aggregate instance) the same buffer is returned. The implementation** of the aggregate can use the returned buffer to accumulate data.**** The buffer allocated is freed automatically by SQLite.*/void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);/*** The pUserData parameter to the sqlite3_create_function()** routine used to register user functions is available to** the implementation of the function using this call.*/void *sqlite3_user_data(sqlite3_context*);/*** The following two functions may be used by scalar user functions to** associate meta-data with argument values. If the same value is passed to** multiple invocations of the user-function during query execution, under** some circumstances the associated meta-data may be preserved. This may** be used, for example, to add a regular-expression matching scalar** function. The compiled version of the regular expression is stored as** meta-data associated with the SQL value passed as the regular expression** pattern.**** Calling sqlite3_get_auxdata() returns a pointer to the meta data** associated with the Nth argument value to the current user function** call, where N is the second parameter. If no meta-data has been set for** that value, then a NULL pointer is returned.**** The sqlite3_set_auxdata() is used to associate meta data with a user** function argument. The third parameter is a pointer to the meta data** to be associated with the Nth user function argument value. The fourth** parameter specifies a 'delete function' that will be called on the meta** data pointer to release it when it is no longer required. If the delete** function pointer is NULL, it is not invoked.**** In practice, meta-data is preserved between function calls for** expressions that are constant at compile time. This includes literal** values and SQL variables.*/void *sqlite3_get_auxdata(sqlite3_context*, int);void sqlite3_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));/*** These are special value for the destructor that is passed in as the** final argument to routines like sqlite3_result_blob(). If the destructor** argument is SQLITE_STATIC, it means that the content pointer is constant** and will never change. It does not need to be destroyed. The ** SQLITE_TRANSIENT value means that the content will likely change in** the near future and that SQLite should make its own private copy of** the content before returning.*/#define SQLITE_STATIC ((void(*)(void *))0)#define SQLITE_TRANSIENT ((void(*)(void *))-1)/*** User-defined functions invoke the following routines in order to** set their return value.*/void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));void sqlite3_result_double(sqlite3_context*, double);void sqlite3_result_error(sqlite3_context*, const char*, int);void sqlite3_result_error16(sqlite3_context*, const void*, int);void sqlite3_result_int(sqlite3_context*, int);void sqlite3_result_int64(sqlite3_context*, sqlite_int64);void sqlite3_result_null(sqlite3_context*);void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));void sqlite3_result_value(sqlite3_context*, sqlite3_value*);/*** These are the allowed values for the eTextRep argument to** sqlite3_create_collation and sqlite3_create_function.*/#define SQLITE_UTF8 1#define SQLITE_UTF16LE 2#define SQLITE_UTF16BE 3#define SQLITE_UTF16 4 /* Use native byte order */#define SQLITE_ANY 5 /* sqlite3_create_function only */#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only *//*** These two functions are used to add new collation sequences to the** sqlite3 handle specified as the first argument. **** The name of the new collation sequence is specified as a UTF-8 string** for sqlite3_create_collation() and a UTF-16 string for** sqlite3_create_collation16(). In both cases the name is passed as the** second function argument.**** The third argument must be one of the constants SQLITE_UTF8,** SQLITE_UTF16LE or SQLITE_UTF16BE, indicating that the user-supplied** routine expects to be passed pointers to strings encoded using UTF-8,** UTF-16 little-endian or UTF-16 big-endian respectively.**** A pointer to the user supplied routine must be passed as the fifth** argument. If it is NULL, this is the same as deleting the collation** sequence (so that SQLite cannot call it anymore). Each time the user** supplied function is invoked, it is passed a copy of the void* passed as** the fourth argument to sqlite3_create_collation() or** sqlite3_create_collation16() as its first parameter.**** The remaining arguments to the user-supplied routine are two strings,** each represented by a [length, data] pair and encoded in the encoding** that was passed as the third argument when the collation sequence was** registered. The user routine should return negative, zero or positive if** the first string is less than, equal to, or greater than the second** string. i.e. (STRING1 - STRING2).*/int sqlite3_create_collation( sqlite3*, const char *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*));int sqlite3_create_collation16( sqlite3*, const char *zName, int eTextRep, void*, int(*xCompare)(void*,int,const void*,int,const void*));/*** To avoid having to register all collation sequences before a database** can be used, a single callback function may be registered with the** database handle to be called whenever an undefined collation sequence is** required.**** If the function is registered using the sqlite3_collation_needed() API,** then it is passed the names of undefined collation sequences as strings** encoded in UTF-8. If sqlite3_collation_needed16() is used, the names** are passed as UTF-16 in machine native byte order. A call to either** function replaces any existing callback.**** When the user-function is invoked, the first argument passed is a copy** of the second argument to sqlite3_collation_needed() or** sqlite3_collation_needed16(). The second argument is the database** handle. The third argument is one of SQLITE_UTF8, SQLITE_UTF16BE or** SQLITE_UTF16LE, indicating the most desirable form of the collation** sequence function required. The fourth parameter is the name of the** required collation sequence.**** The collation sequence is returned to SQLite by a collation-needed** callback using the sqlite3_create_collation() or** sqlite3_create_collation16() APIs, described above.*/int sqlite3_collation_needed( sqlite3*, void*, void(*)(void*,sqlite3*,int eTextRep,const char*));int sqlite3_collation_needed16( sqlite3*,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -