|
void *sqlite3_get_auxdata(sqlite3_context*, int); void sqlite3_set_auxdata(sqlite3_context*, int, void*, void (*)(void*));
The following two functions may be used by scalar SQL functions to associate meta-data with argument values. If the same value is passed to multiple invocations of the same SQL 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. The compiled regular expression can be reused on multiple invocations of the same function so that the original pattern string does not need to be recompiled on each invocation.
The sqlite3_get_auxdata() interface returns a pointer to the meta-data associated with the Nth argument value to the current SQL 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 an SQL 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 destructor that will be called on the meta- data pointer to release it when it is no longer required. If the destructor 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.
These routines must be called from the same thread in which the SQL function is running.
See also lists of Objects, Constants, and Functions.