|
void *sqlite3_get_auxdata(sqlite3_context*, int N); void sqlite3_set_auxdata(sqlite3_context*, int N, 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 by the sqlite3_set_auxdata() function with the Nth argument value to the application-defined function. If no meta-data has been ever been set for the Nth argument of the function, or if the cooresponding function parameter has changed since the meta-data was set, then sqlite3_get_auxdata() returns a NULL pointer.
The sqlite3_set_auxdata() interface saves the meta-data pointed to by its 3rd parameter as the meta-data for the N-th argument of the application-defined function. Subsequent calls to sqlite3_get_auxdata() might return this data, if it has not been destroyed. If it is not NULL, SQLite will invoke the destructor function given by the 4th parameter to sqlite3_set_auxdata() on the meta-data when the corresponding function parameter changes or when the SQL statement completes, whichever comes first.
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.