aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/src/test_loadext.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/src/test_loadext.c')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/src/test_loadext.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/src/test_loadext.c b/libraries/sqlite/unix/sqlite-3.5.1/src/test_loadext.c
new file mode 100644
index 0000000..1204971
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/src/test_loadext.c
@@ -0,0 +1,57 @@
1/*
2** 2006 June 14
3**
4** The author disclaims copyright to this source code. In place of
5** a legal notice, here is a blessing:
6**
7** May you do good and not evil.
8** May you find forgiveness for yourself and forgive others.
9** May you share freely, never taking more than you give.
10**
11*************************************************************************
12** Test extension for testing the sqlite3_load_extension() function.
13**
14** $Id: test_loadext.c,v 1.1 2006/06/14 10:38:03 danielk1977 Exp $
15*/
16
17#include "sqlite3ext.h"
18SQLITE_EXTENSION_INIT1
19
20/*
21** The half() SQL function returns half of its input value.
22*/
23static void halfFunc(
24 sqlite3_context *context,
25 int argc,
26 sqlite3_value **argv
27){
28 sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0]));
29}
30
31/*
32** Extension load function.
33*/
34int testloadext_init(
35 sqlite3 *db,
36 char **pzErrMsg,
37 const sqlite3_api_routines *pApi
38){
39 SQLITE_EXTENSION_INIT2(pApi);
40 sqlite3_create_function(db, "half", 1, SQLITE_ANY, 0, halfFunc, 0, 0);
41 return 0;
42}
43
44/*
45** Another extension entry point. This one always fails.
46*/
47int testbrokenext_init(
48 sqlite3 *db,
49 char **pzErrMsg,
50 const sqlite3_api_routines *pApi
51){
52 char *zErr;
53 SQLITE_EXTENSION_INIT2(pApi);
54 zErr = sqlite3_mprintf("broken!");
55 *pzErrMsg = zErr;
56 return 1;
57}