mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
Add the sqlite3_create_function_v2() API, a version of create_function that allows a destructor to be specified.
FossilOrigin-Name: 9a724dfbe822c77e76721abe3443c9cb018bb2e2
This commit is contained in:
@@ -600,6 +600,7 @@ typedef struct Expr Expr;
|
||||
typedef struct ExprList ExprList;
|
||||
typedef struct ExprSpan ExprSpan;
|
||||
typedef struct FKey FKey;
|
||||
typedef struct FuncDestructor FuncDestructor;
|
||||
typedef struct FuncDef FuncDef;
|
||||
typedef struct FuncDefHash FuncDefHash;
|
||||
typedef struct IdList IdList;
|
||||
@@ -956,6 +957,27 @@ struct FuncDef {
|
||||
void (*xFinalize)(sqlite3_context*); /* Aggregate finalizer */
|
||||
char *zName; /* SQL name of the function. */
|
||||
FuncDef *pHash; /* Next with a different name but the same hash */
|
||||
FuncDestructor *pDestructor; /* Reference counted destructor function */
|
||||
};
|
||||
|
||||
/*
|
||||
** This structure encapsulates a user-function destructor callback (as
|
||||
** configured using create_function_v2()) and a reference counter. When
|
||||
** create_function_v2() is called to create a function with a destructor,
|
||||
** a single object of this type is allocated. FuncDestructor.nRef is set to
|
||||
** the number of FuncDef objects created (either 1 or 3, depending on whether
|
||||
** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor
|
||||
** member of each of the new FuncDef objects is set to point to the allocated
|
||||
** FuncDestructor.
|
||||
**
|
||||
** Thereafter, when one of the FuncDef objects is deleted, the reference
|
||||
** count on this object is decremented. When it reaches 0, the destructor
|
||||
** is invoked and the FuncDestructor structure freed.
|
||||
*/
|
||||
struct FuncDestructor {
|
||||
int nRef;
|
||||
void (*xDestroy)(void *);
|
||||
void *pUserData;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -2921,7 +2943,9 @@ int sqlite3SchemaToIndex(sqlite3 *db, Schema *);
|
||||
KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);
|
||||
int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **),
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*));
|
||||
void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
|
||||
FuncDestructor *pDestructor
|
||||
);
|
||||
int sqlite3ApiExit(sqlite3 *db, int);
|
||||
int sqlite3OpenTempDatabase(Parse *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user