test_extension.c 588 B

123456789101112131415161718192021
  1. #include <sqlite3ext.h>
  2. SQLITE_EXTENSION_INIT1
  3. /*
  4. This SQLite3 extension is used only for testing purposes (npm test).
  5. */
  6. static void TestExtensionFunction(sqlite3_context* pCtx, int nVal, sqlite3_value** _) {
  7. sqlite3_result_double(pCtx, (double)nVal);
  8. }
  9. #ifdef _WIN32
  10. __declspec(dllexport)
  11. #endif
  12. int sqlite3_extension_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* pApi) {
  13. SQLITE_EXTENSION_INIT2(pApi)
  14. if (pzErrMsg != 0) *pzErrMsg = 0;
  15. sqlite3_create_function(db, "testExtensionFunction", -1, SQLITE_UTF8, 0, TestExtensionFunction, 0, 0);
  16. return SQLITE_OK;
  17. }