Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/misc/noop.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / misc / noop.c` 102 lines ยท 2893 bytes Raw Blame History 1 /* 2 ** 2020-01-08 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 ** 13 ** This SQLite extension implements a noop() function originally intended 14 ** to be used for testing purposes only, but never actually used for anything 15 ** beyond interactive testing. 16 ** 17 ** Variants: 18 ** 19 ** noop(X) The default. Deterministic. 20 ** noop_i(X) Deterministic and innocuous. 21 ** noop_do(X) Deterministic and direct-only. 22 ** noop_nd(X) Non-deterministic. 23 */ 24 #include "sqlite3ext.h" 25 SQLITE_EXTENSION_INIT1 26 #include 27 #include 28 29 /* 30 ** Implementation of the noop() function. 31 ** 32 ** The function returns its argument, unchanged. 33 */ 34 static void noopfunc( 35 sqlite3_context *context, 36 int argc, 37 sqlite3_value **argv 38 ){ 39 assert( argc==1 ); 40 sqlite3_result_value(context, argv[0]); 41 } 42 43 /* 44 ** Implementation of the multitype_text() function. 45 ** 46 ** The function returns its argument as text. 47 ** 48 ** * TEXT inputs are passed through unchanged 49 ** 50 ** * BLOB inputs return TEXT that is the original BLOB 51 ** interpreted as UTF-8. If the BLOB contains a 0x00 52 ** byte, that byte is interpreted as the string 53 ** terminator. 54 ** 55 ** * INTEGER or REAL inputs return a TEXT representation of 56 ** the number. 57 ** 58 ** * NULL inputs return NULL 59 */ 60 static void multitypeTextFunc( 61 sqlite3_context *context, 62 int argc, 63 sqlite3_value **argv 64 ){ 65 assert( argc==1 ); 66 (void)argc; 67 (void)sqlite3_value_text(argv[0]); 68 sqlite3_result_value(context, argv[0]); 69 } 70 71 #ifdef _WIN32 72 __declspec(dllexport) 73 #endif 74 int sqlite3_noop_init( 75 sqlite3 *db, 76 char **pzErrMsg, 77 const sqlite3_api_routines *pApi 78 ){ 79 int rc = SQLITE_OK; 80 SQLITE_EXTENSION_INIT2(pApi); 81 (void)pzErrMsg; /* Unused parameter */ 82 rc = sqlite3_create_function(db, "noop", 1, 83 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 84 0, noopfunc, 0, 0); 85 if( rc ) return rc; 86 rc = sqlite3_create_function(db, "noop_i", 1, 87 SQLITE_UTF8 | SQLITE_DETERMINISTIC | SQLITE_INNOCUOUS, 88 0, noopfunc, 0, 0); 89 if( rc ) return rc; 90 rc = sqlite3_create_function(db, "noop_do", 1, 91 SQLITE_UTF8 | SQLITE_DETERMINISTIC | SQLITE_DIRECTONLY, 92 0, noopfunc, 0, 0); 93 if( rc ) return rc; 94 rc = sqlite3_create_function(db, "noop_nd", 1, 95 SQLITE_UTF8, 96 0, noopfunc, 0, 0); 97 if( rc ) return rc; 98 rc = sqlite3_create_function(db, "multitype_text", 1, 99 SQLITE_UTF8, 100 0, multitypeTextFunc, 0, 0); 101 return rc; 102 }