4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
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.
11 ******************************************************************************
13 ** This SQLite extension implements a noop() function used for testing.
17 ** noop(X) The default. Deterministic.
18 ** noop_i(X) Deterministic and innocuous.
19 ** noop_do(X) Deterministic and direct-only.
20 ** noop_nd(X) Non-deterministic.
22 #include "sqlite3ext.h"
23 SQLITE_EXTENSION_INIT1
28 ** Implementation of the noop() function.
30 ** The function returns its argument, unchanged.
33 sqlite3_context
*context
,
38 sqlite3_result_value(context
, argv
[0]);
42 ** Implementation of the multitype_text() function.
44 ** The function returns its argument. The result will always have a
45 ** TEXT value. But if the original input is numeric, it will also
46 ** have that numeric value.
48 static void multitypeTextFunc(
49 sqlite3_context
*context
,
55 (void)sqlite3_value_text(argv
[0]);
56 sqlite3_result_value(context
, argv
[0]);
62 int sqlite3_noop_init(
65 const sqlite3_api_routines
*pApi
68 SQLITE_EXTENSION_INIT2(pApi
);
69 (void)pzErrMsg
; /* Unused parameter */
70 rc
= sqlite3_create_function(db
, "noop", 1,
71 SQLITE_UTF8
| SQLITE_DETERMINISTIC
,
74 rc
= sqlite3_create_function(db
, "noop_i", 1,
75 SQLITE_UTF8
| SQLITE_DETERMINISTIC
| SQLITE_INNOCUOUS
,
78 rc
= sqlite3_create_function(db
, "noop_do", 1,
79 SQLITE_UTF8
| SQLITE_DETERMINISTIC
| SQLITE_DIRECTONLY
,
82 rc
= sqlite3_create_function(db
, "noop_nd", 1,
86 rc
= sqlite3_create_function(db
, "multitype_text", 1,
88 0, multitypeTextFunc
, 0, 0);