1
/* This code is to test extension loading and is taken from
2
http://www.sqlite.org/cvstrac/wiki/wiki?p=LoadableExtensions */
5
#include <sqlite3ext.h>
9
** The half() SQL function returns half of its input value.
12
sqlite3_context *context,
16
sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0]));
19
/* SQLite invokes this routine once when it loads the extension.
20
** Create new functions, collating sequences, and virtual table
21
** modules here. This is usually the only exported symbol in
22
** the shared library.
24
int sqlite3_extension_init(
27
const sqlite3_api_routines *pApi
29
SQLITE_EXTENSION_INIT2(pApi)
30
sqlite3_create_function(db, "half", 1, SQLITE_ANY, 0, halfFunc, 0, 0);
35
/* this is code added by me and checks that alternate entry points work by
36
providing an double function */
38
static void doubleFunc(
39
sqlite3_context *context,
43
sqlite3_result_double(context, 2.0*sqlite3_value_double(argv[0]));
46
int alternate_sqlite3_extension_init(
49
const sqlite3_api_routines *pApi
51
SQLITE_EXTENSION_INIT2(pApi)
52
sqlite3_create_function(db, "doubleup", 1, SQLITE_ANY, 0, doubleFunc, 0, 0);