1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

sqlite - add test extension - half.c

This commit is contained in:
Dave Conway-Jones 2018-08-23 08:55:51 +01:00
parent 0b65cd8652
commit 6d36f5db8a
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 30 additions and 0 deletions

30
storage/sqlite/ext/half.c Normal file
View File

@ -0,0 +1,30 @@
/* Add your header comment here */
#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1
/*
** The half() SQL function returns half of its input value.
*/
static void halfFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0]));
}
/* SQLite invokes this routine once when it loads the extension.
** Create new functions, collating sequences, and virtual table
** modules here. This is usually the only exported symbol in
** the shared library.
*/
int sqlite3_extension_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
SQLITE_EXTENSION_INIT2(pApi)
sqlite3_create_function(db, "half", 1, SQLITE_ANY, 0, halfFunc, 0, 0);
return 0;
}

BIN
storage/sqlite/ext/half.dylib Executable file

Binary file not shown.