Add initial support for building with extensions
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include <sqlite3ext.h>
|
||||
|
||||
SQLITE_EXTENSION_INIT1
|
||||
|
||||
static void sub_func(
|
||||
sqlite3_context *ctx,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
) {
|
||||
if (argc != 2) {
|
||||
sqlite3_result_null(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
int a = sqlite3_value_int(argv[0]);
|
||||
int b = sqlite3_value_int(argv[1]);
|
||||
|
||||
sqlite3_result_int(ctx, a - b);
|
||||
}
|
||||
|
||||
int sqlite3_subext_init(
|
||||
sqlite3 *db,
|
||||
char **pzErrMsg,
|
||||
const sqlite3_api_routines *pApi
|
||||
) {
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
|
||||
return sqlite3_create_function(
|
||||
db,
|
||||
"sub",
|
||||
2,
|
||||
SQLITE_UTF8 | SQLITE_DETERMINISTIC,
|
||||
0,
|
||||
sub_func,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user