aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/api')
-rw-r--r--ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth1
-rw-r--r--ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core3
-rw-r--r--ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras (renamed from ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session)21
-rw-r--r--ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate6
-rw-r--r--ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab11
-rw-r--r--ext/wasm/api/sqlite3-api-glue.c-pp.js157
-rw-r--r--ext/wasm/api/sqlite3-wasm.c178
7 files changed, 184 insertions, 193 deletions
diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth
deleted file mode 100644
index 085090821..000000000
--- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-auth
+++ /dev/null
@@ -1 +0,0 @@
-_sqlite3_set_authorizer
diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core
index db47ee7db..2578002ce 100644
--- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core
+++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-core
@@ -41,7 +41,6 @@ _sqlite3_create_collation
_sqlite3_create_collation_v2
_sqlite3_create_function
_sqlite3_create_function_v2
-_sqlite3_create_window_function
_sqlite3_data_count
_sqlite3_db_filename
_sqlite3_db_handle
@@ -49,7 +48,6 @@ _sqlite3_db_name
_sqlite3_db_readonly
_sqlite3_db_status
_sqlite3_deserialize
-_sqlite3_drop_modules
_sqlite3_errcode
_sqlite3_errmsg
_sqlite3_error_offset
@@ -81,7 +79,6 @@ _sqlite3_open_v2
_sqlite3_overload_function
_sqlite3_prepare_v2
_sqlite3_prepare_v3
-_sqlite3_progress_handler
_sqlite3_randomness
_sqlite3_realloc
_sqlite3_realloc64
diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras
index 5b7b53f95..e635d93b3 100644
--- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-session
+++ b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-extras
@@ -1,3 +1,12 @@
+_sqlite3_create_window_function
+_sqlite3_progress_handler
+_sqlite3_set_authorizer
+_sqlite3_preupdate_blobwrite
+_sqlite3_preupdate_count
+_sqlite3_preupdate_depth
+_sqlite3_preupdate_hook
+_sqlite3_preupdate_new
+_sqlite3_preupdate_old
_sqlite3changegroup_add
_sqlite3changegroup_add_strm
_sqlite3changegroup_delete
@@ -40,3 +49,15 @@ _sqlite3session_object_config
_sqlite3session_patchset
_sqlite3session_patchset_strm
_sqlite3session_table_filter
+_sqlite3_create_module
+_sqlite3_create_module_v2
+_sqlite3_declare_vtab
+_sqlite3_drop_modules
+_sqlite3_vtab_collation
+_sqlite3_vtab_distinct
+_sqlite3_vtab_in
+_sqlite3_vtab_in_first
+_sqlite3_vtab_in_next
+_sqlite3_vtab_nochange
+_sqlite3_vtab_on_conflict
+_sqlite3_vtab_rhs_value
diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate
deleted file mode 100644
index 5c57a76b6..000000000
--- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-preupdate
+++ /dev/null
@@ -1,6 +0,0 @@
-_sqlite3_preupdate_blobwrite
-_sqlite3_preupdate_count
-_sqlite3_preupdate_depth
-_sqlite3_preupdate_hook
-_sqlite3_preupdate_new
-_sqlite3_preupdate_old
diff --git a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab b/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab
deleted file mode 100644
index 1f6de9682..000000000
--- a/ext/wasm/api/EXPORTED_FUNCTIONS.sqlite3-vtab
+++ /dev/null
@@ -1,11 +0,0 @@
-_sqlite3_create_module
-_sqlite3_create_module_v2
-_sqlite3_declare_vtab
-_sqlite3_vtab_collation
-_sqlite3_vtab_distinct
-_sqlite3_vtab_in
-_sqlite3_vtab_in_first
-_sqlite3_vtab_in_next
-_sqlite3_vtab_nochange
-_sqlite3_vtab_on_conflict
-_sqlite3_vtab_rhs_value
diff --git a/ext/wasm/api/sqlite3-api-glue.c-pp.js b/ext/wasm/api/sqlite3-api-glue.c-pp.js
index e5eb0cfeb..680218370 100644
--- a/ext/wasm/api/sqlite3-api-glue.c-pp.js
+++ b/ext/wasm/api/sqlite3-api-glue.c-pp.js
@@ -136,20 +136,12 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
["sqlite3_compileoption_used", "int", "string"],
["sqlite3_complete", "int", "string:flexible"],
["sqlite3_context_db_handle", "sqlite3*", "sqlite3_context*"],
-
+ /* sqlite3_create_collation() and sqlite3_create_collation_v2()
+ use hand-written bindings to simplify passing of the callback
+ function. */
/* sqlite3_create_function(), sqlite3_create_function_v2(), and
sqlite3_create_window_function() use hand-written bindings to
simplify handling of their function-type arguments. */
- /* sqlite3_create_collation() and sqlite3_create_collation_v2()
- use hand-written bindings to simplify passing of the callback
- function.
- ["sqlite3_create_collation", "int",
- "sqlite3*", "string", "int",//SQLITE_UTF8 is the only legal value
- "*", "*"],
- ["sqlite3_create_collation_v2", "int",
- "sqlite3*", "string", "int",//SQLITE_UTF8 is the only legal value
- "*", "*", "*"],
- */
["sqlite3_data_count", "int", "sqlite3_stmt*"],
["sqlite3_db_filename", "string", "sqlite3*", "string"],
["sqlite3_db_handle", "sqlite3*", "sqlite3_stmt*"],
@@ -211,14 +203,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
for those, depending on how their SQL argument is provided. */
/* sqlite3_randomness() uses a hand-written wrapper to extend
the range of supported argument types. */
- ["sqlite3_progress_handler", undefined, [
- "sqlite3*", "int", new wasm.xWrap.FuncPtrAdapter({
- name: 'xProgressHandler',
- signature: 'i(p)',
- bindScope: 'context',
- contextKey: (argv,argIndex)=>argv[0/* sqlite3* */]
- }), "*"
- ]],
["sqlite3_realloc", "*","*","int"],
["sqlite3_reset", "int", "sqlite3_stmt*"],
/* sqlite3_reset_auto_extension() has a hand-written binding. */
@@ -303,6 +287,19 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
["sqlite3_vfs_unregister", "int", "sqlite3_vfs*"]
]/*wasm.bindingSignatures*/;
+ if( !!wasm.exports.sqlite3_progress_handler ){
+ wasm.bindingSignatures.push(
+ ["sqlite3_progress_handler", undefined, [
+ "sqlite3*", "int", new wasm.xWrap.FuncPtrAdapter({
+ name: 'xProgressHandler',
+ signature: 'i(p)',
+ bindScope: 'context',
+ contextKey: (argv,argIndex)=>argv[0/* sqlite3* */]
+ }), "*"
+ ]]
+ );
+ }
+
if( !!wasm.exports.sqlite3_stmt_explain ){
wasm.bindingSignatures.push(
["sqlite3_stmt_explain", "int", "sqlite3_stmt*", "int"],
@@ -336,7 +333,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
}/* sqlite3_set_authorizer() */
if(false && wasm.compileOptionUsed('SQLITE_ENABLE_NORMALIZE')){
- /* ^^^ "the problem" is that this is an option feature and the
+ /* ^^^ "the problem" is that this is an optional feature and the
build-time function-export list does not currently take
optional features into account. */
wasm.bindingSignatures.push(["sqlite3_normalized_sql", "string", "sqlite3_stmt*"]);
@@ -385,7 +382,6 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
of this, the canonical builds of sqlite3.wasm/js guarantee that
sqlite3.wasm.alloc() and friends use those allocators. Custom builds
may not guarantee that, however. */,
- ["sqlite3_drop_modules", "int", ["sqlite3*", "**"]],
["sqlite3_last_insert_rowid", "i64", ["sqlite3*"]],
["sqlite3_malloc64", "*","i64"],
["sqlite3_msize", "i64", "*"],
@@ -422,6 +418,7 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
["sqlite3_create_module_v2", "int",
["sqlite3*","string","sqlite3_module*","*","*"]],
["sqlite3_declare_vtab", "int", ["sqlite3*", "string:flexible"]],
+ ["sqlite3_drop_modules", "int", ["sqlite3*", "**"]],
["sqlite3_vtab_collation","string","sqlite3_index_info*","int"],
["sqlite3_vtab_distinct","int", "sqlite3_index_info*"],
["sqlite3_vtab_in","int", "sqlite3_index_info*", "int", "int"],
@@ -950,7 +947,8 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
/** Code duplication reducer for functions which take an encoding
argument and require SQLITE_UTF8. Sets the db error code to
- SQLITE_FORMAT and returns that code. */
+ SQLITE_FORMAT, installs a descriptive error message,
+ and returns SQLITE_FORMAT. */
const __errEncoding = (pDb)=>{
return util.sqlite3__wasm_db_error(
pDb, capi.SQLITE_FORMAT, "SQLITE_UTF8 is the only supported encoding."
@@ -1000,11 +998,13 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
this._addUDF(pDb, name, arity, m.udf);
};
- __dbCleanupMap.addWindowFunc = function(pDb, name, arity){
- const m = __dbCleanupMap(pDb, 1);
- if(!m.wudf) m.wudf = new Map;
- this._addUDF(pDb, name, arity, m.wudf);
- };
+ if( wasm.exports.sqlite3_create_window_function ){
+ __dbCleanupMap.addWindowFunc = function(pDb, name, arity){
+ const m = __dbCleanupMap(pDb, 1);
+ if(!m.wudf) m.wudf = new Map;
+ this._addUDF(pDb, name, arity, m.wudf);
+ };
+ }
/**
Intended to be called _only_ from sqlite3_close_v2(),
@@ -1273,17 +1273,20 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
]
);
- const __sqlite3CreateWindowFunction = wasm.xWrap(
- "sqlite3_create_window_function", "int", [
- "sqlite3*", "string"/*funcName*/, "int"/*nArg*/,
- "int"/*eTextRep*/, "*"/*pApp*/,
- new wasm.xWrap.FuncPtrAdapter({name: 'xStep', ...__cfProxy.xInverseAndStep}),
- new wasm.xWrap.FuncPtrAdapter({name: 'xFinal', ...__cfProxy.xFinalAndValue}),
- new wasm.xWrap.FuncPtrAdapter({name: 'xValue', ...__cfProxy.xFinalAndValue}),
- new wasm.xWrap.FuncPtrAdapter({name: 'xInverse', ...__cfProxy.xInverseAndStep}),
- new wasm.xWrap.FuncPtrAdapter({name: 'xDestroy', ...__cfProxy.xDestroy})
- ]
- );
+ const __sqlite3CreateWindowFunction =
+ wasm.exports.sqlite3_create_window_function
+ ? wasm.xWrap(
+ "sqlite3_create_window_function", "int", [
+ "sqlite3*", "string"/*funcName*/, "int"/*nArg*/,
+ "int"/*eTextRep*/, "*"/*pApp*/,
+ new wasm.xWrap.FuncPtrAdapter({name: 'xStep', ...__cfProxy.xInverseAndStep}),
+ new wasm.xWrap.FuncPtrAdapter({name: 'xFinal', ...__cfProxy.xFinalAndValue}),
+ new wasm.xWrap.FuncPtrAdapter({name: 'xValue', ...__cfProxy.xFinalAndValue}),
+ new wasm.xWrap.FuncPtrAdapter({name: 'xInverse', ...__cfProxy.xInverseAndStep}),
+ new wasm.xWrap.FuncPtrAdapter({name: 'xDestroy', ...__cfProxy.xDestroy})
+ ]
+ )
+ : undefined;
/* Documented in the api object's initializer. */
capi.sqlite3_create_function_v2 = function f(
@@ -1328,61 +1331,71 @@ globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
};
/* Documented in the api object's initializer. */
- capi.sqlite3_create_window_function = function f(
- pDb, funcName, nArg, eTextRep, pApp,
- xStep, //void (*xStep)(sqlite3_context*,int,sqlite3_value**)
- xFinal, //void (*xFinal)(sqlite3_context*)
- xValue, //void (*xValue)(sqlite3_context*)
- xInverse,//void (*xInverse)(sqlite3_context*,int,sqlite3_value**)
- xDestroy //void (*xDestroy)(void*)
- ){
- if( f.length!==arguments.length ){
- return __dbArgcMismatch(pDb,"sqlite3_create_window_function",f.length);
- }else if( 0 === (eTextRep & 0xf) ){
- eTextRep |= capi.SQLITE_UTF8;
- }else if( capi.SQLITE_UTF8 !== (eTextRep & 0xf) ){
- return __errEncoding(pDb);
- }
- try{
- const rc = __sqlite3CreateWindowFunction(pDb, funcName, nArg, eTextRep,
- pApp, xStep, xFinal, xValue,
- xInverse, xDestroy);
- if(0===rc && (xStep instanceof Function
- || xFinal instanceof Function
- || xValue instanceof Function
- || xInverse instanceof Function
- || xDestroy instanceof Function)){
- __dbCleanupMap.addWindowFunc(pDb, funcName, nArg);
+ if( __sqlite3CreateWindowFunction ){
+ capi.sqlite3_create_window_function = function f(
+ pDb, funcName, nArg, eTextRep, pApp,
+ xStep, //void (*xStep)(sqlite3_context*,int,sqlite3_value**)
+ xFinal, //void (*xFinal)(sqlite3_context*)
+ xValue, //void (*xValue)(sqlite3_context*)
+ xInverse,//void (*xInverse)(sqlite3_context*,int,sqlite3_value**)
+ xDestroy //void (*xDestroy)(void*)
+ ){
+ if( f.length!==arguments.length ){
+ return __dbArgcMismatch(pDb,"sqlite3_create_window_function",f.length);
+ }else if( 0 === (eTextRep & 0xf) ){
+ eTextRep |= capi.SQLITE_UTF8;
+ }else if( capi.SQLITE_UTF8 !== (eTextRep & 0xf) ){
+ return __errEncoding(pDb);
}
- return rc;
- }catch(e){
- console.error("sqlite3_create_window_function() setup threw:",e);
- return util.sqlite3__wasm_db_error(pDb, e, "Creation of UDF threw: "+e);
- }
- };
+ try{
+ const rc = __sqlite3CreateWindowFunction(pDb, funcName, nArg, eTextRep,
+ pApp, xStep, xFinal, xValue,
+ xInverse, xDestroy);
+ if(0===rc && (xStep instanceof Function
+ || xFinal instanceof Function
+ || xValue instanceof Function
+ || xInverse instanceof Function
+ || xDestroy instanceof Function)){
+ __dbCleanupMap.addWindowFunc(pDb, funcName, nArg);
+ }
+ return rc;
+ }catch(e){
+ console.error("sqlite3_create_window_function() setup threw:",e);
+ return util.sqlite3__wasm_db_error(pDb, e, "Creation of UDF threw: "+e);
+ }
+ };
+ }else{
+ delete capi.sqlite3_create_window_function;
+ }
/**
A _deprecated_ alias for capi.sqlite3_result_js() which
predates the addition of that function in the public API.
*/
capi.sqlite3_create_function_v2.udfSetResult =
- capi.sqlite3_create_function.udfSetResult =
+ capi.sqlite3_create_function.udfSetResult = capi.sqlite3_result_js;
+ if(capi.sqlite3_create_window_function){
capi.sqlite3_create_window_function.udfSetResult = capi.sqlite3_result_js;
+ }
/**
A _deprecated_ alias for capi.sqlite3_values_to_js() which
predates the addition of that function in the public API.
*/
capi.sqlite3_create_function_v2.udfConvertArgs =
- capi.sqlite3_create_function.udfConvertArgs =
+ capi.sqlite3_create_function.udfConvertArgs = capi.sqlite3_values_to_js;
+ if(capi.sqlite3_create_window_function){
capi.sqlite3_create_window_function.udfConvertArgs = capi.sqlite3_values_to_js;
+ }
/**
A _deprecated_ alias for capi.sqlite3_result_error_js() which
predates the addition of that function in the public API.
*/
capi.sqlite3_create_function_v2.udfSetError =
- capi.sqlite3_create_function.udfSetError =
+ capi.sqlite3_create_function.udfSetError = capi.sqlite3_result_error_js;
+ if(capi.sqlite3_create_window_function){
capi.sqlite3_create_window_function.udfSetError = capi.sqlite3_result_error_js;
+ }
}/*sqlite3_create_function_v2() and sqlite3_create_window_function() proxies*/;
diff --git a/ext/wasm/api/sqlite3-wasm.c b/ext/wasm/api/sqlite3-wasm.c
index 7f7e69689..c5dd495e5 100644
--- a/ext/wasm/api/sqlite3-wasm.c
+++ b/ext/wasm/api/sqlite3-wasm.c
@@ -14,16 +14,17 @@
*/
#define SQLITE_WASM
#ifdef SQLITE_WASM_ENABLE_C_TESTS
+# undef SQLITE_WASM_ENABLE_C_TESTS
+# define SQLITE_WASM_ENABLE_C_TESTS 1
/*
-** Code blocked off by SQLITE_WASM_TESTS is intended solely for use in
-** unit/regression testing. They may be safely omitted from
+** Code blocked off by SQLITE_WASM_ENABLE_C_TESTS is intended solely
+** for use in unit/regression testing. They may be safely omitted from
** client-side builds. The main unit test script, tester1.js, will
** skip related tests if it doesn't find the corresponding functions
** in the WASM exports.
*/
-# define SQLITE_WASM_TESTS 1
#else
-# define SQLITE_WASM_TESTS 0
+# define SQLITE_WASM_ENABLE_C_TESTS 0
#endif
/*
@@ -92,60 +93,18 @@
#undef SQLITE_ENABLE_API_ARMOR
#define SQLITE_ENABLE_API_ARMOR 1
-#ifndef SQLITE_ENABLE_BYTECODE_VTAB
-# define SQLITE_ENABLE_BYTECODE_VTAB 1
-#endif
-#ifndef SQLITE_ENABLE_DBPAGE_VTAB
-# define SQLITE_ENABLE_DBPAGE_VTAB 1
-#endif
-#ifndef SQLITE_ENABLE_DBSTAT_VTAB
-# define SQLITE_ENABLE_DBSTAT_VTAB 1
-#endif
-#ifndef SQLITE_ENABLE_EXPLAIN_COMMENTS
-# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
-#endif
-#ifndef SQLITE_ENABLE_FTS5
-# define SQLITE_ENABLE_FTS5 1
-#endif
-#ifndef SQLITE_ENABLE_MATH_FUNCTIONS
-# define SQLITE_ENABLE_MATH_FUNCTIONS 1
-#endif
-#ifndef SQLITE_ENABLE_OFFSET_SQL_FUNC
-# define SQLITE_ENABLE_OFFSET_SQL_FUNC 1
-#endif
-#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
-# define SQLITE_ENABLE_PREUPDATE_HOOK 1 /*required by session extension*/
-#endif
-#ifndef SQLITE_ENABLE_RTREE
-# define SQLITE_ENABLE_RTREE 1
-#endif
-#ifndef SQLITE_ENABLE_SESSION
-# define SQLITE_ENABLE_SESSION 1
-#endif
-#ifndef SQLITE_ENABLE_STMTVTAB
-# define SQLITE_ENABLE_STMTVTAB 1
-#endif
-#ifndef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
-# define SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
-#endif
-
/**********************************************************************/
/* SQLITE_O... */
-#ifndef SQLITE_OMIT_DEPRECATED
-# define SQLITE_OMIT_DEPRECATED 1
-#endif
-#ifndef SQLITE_OMIT_LOAD_EXTENSION
-# define SQLITE_OMIT_LOAD_EXTENSION 1
-#endif
-#ifndef SQLITE_OMIT_SHARED_CACHE
-# define SQLITE_OMIT_SHARED_CACHE 1
-#endif
-#ifndef SQLITE_OMIT_UTF16
-# define SQLITE_OMIT_UTF16 1
-#endif
-#ifndef SQLITE_OS_KV_OPTIONAL
-# define SQLITE_OS_KV_OPTIONAL 1
-#endif
+#undef SQLITE_OMIT_DEPRECATED
+#define SQLITE_OMIT_DEPRECATED 1
+#undef SQLITE_OMIT_LOAD_EXTENSION
+#define SQLITE_OMIT_LOAD_EXTENSION 1
+#undef SQLITE_OMIT_SHARED_CACHE
+#define SQLITE_OMIT_SHARED_CACHE 1
+#undef SQLITE_OMIT_UTF16
+#define SQLITE_OMIT_UTF16 1
+#undef SQLITE_OS_KV_OPTIONAL
+#define SQLITE_OS_KV_OPTIONAL 1
/**********************************************************************/
/* SQLITE_S... */
@@ -173,45 +132,64 @@
#endif
/*
-** If SQLITE_WASM_MINIMAL is defined, undefine most of the ENABLE
+** If SQLITE_WASM_BARE_BONES is defined, undefine most of the ENABLE
** macros.
*/
-#ifdef SQLITE_WASM_MINIMAL
-# undef SQLITE_ENABLE_DBPAGE_VTAB
-# undef SQLITE_ENABLE_DBSTAT_VTAB
-# undef SQLITE_ENABLE_EXPLAIN_COMMENTS
-# undef SQLITE_ENABLE_FTS5
-# undef SQLITE_ENABLE_OFFSET_SQL_FUNC
-# undef SQLITE_ENABLE_PREUPDATE_HOOK
-# undef SQLITE_ENABLE_RTREE
-# undef SQLITE_ENABLE_SESSION
-# undef SQLITE_ENABLE_STMTVTAB
-# undef SQLITE_OMIT_AUTHORIZATION
+#ifdef SQLITE_WASM_BARE_BONES
+# undef SQLITE_ENABLE_DBPAGE_VTAB
+# undef SQLITE_ENABLE_DBSTAT_VTAB
+# undef SQLITE_ENABLE_EXPLAIN_COMMENTS
+# undef SQLITE_ENABLE_FTS5
+# undef SQLITE_ENABLE_OFFSET_SQL_FUNC
+# undef SQLITE_ENABLE_PREUPDATE_HOOK
+# undef SQLITE_ENABLE_RTREE
+# undef SQLITE_ENABLE_SESSION
+# undef SQLITE_ENABLE_STMTVTAB
+# undef SQLITE_OMIT_AUTHORIZATION
# define SQLITE_OMIT_AUTHORIZATION
-/*Reminder re. custom sqlite3.c:
+# undef SQLITE_OMIT_GET_TABLE
+# define SQLITE_OMIT_GET_TABLE
+# undef SQLITE_OMIT_INCRBLOB
+# define SQLITE_OMIT_INCRBLOB
+# undef SQLITE_OMIT_INTROSPECTION_PRAGMAS
+# define SQLITE_OMIT_INTROSPECTION_PRAGMAS
+# undef SQLITE_OMIT_JSON
+# define SQLITE_OMIT_JSON
+# undef SQLITE_OMIT_PROGRESS_CALLBACK
+# define SQLITE_OMIT_PROGRESS_CALLBACK
+# undef SQLITE_OMIT_WAL
+# define SQLITE_OMIT_WAL
+/*
+ The following OMITs do not work with the standard amalgamation, so
+ require a custom build:
fossil clean -x
./configure
- OPTS='-DSQLITE_OMIT_VIRTUALTABLE -DSQLITE_OMIT_EXPLAIN -DSQLITE_OMIT_TRIGGER' make -e sqlite3
-*/
-/*Requires a custom sqlite3.c
-# undef SQLITE_OMIT_TRIGGER
-# define SQLITE_OMIT_TRIGGER
-*/
-/*TODO (requires build tweaks)
-# undef SQLITE_OMIT_WINDOWFUNC
-# define SQLITE_OMIT_WINDOWFUNC
-*/
-/*Requires a custom sqlite3.c
+ OPTS='...' make -e sqlite3
+
+ where ... has a -D... for each of the following OMIT flags:
+
# undef SQLITE_OMIT_EXPLAIN
# define SQLITE_OMIT_EXPLAIN
-*/
-/*Requires a custom sqlite3.c
+
+# undef SQLITE_OMIT_TRIGGER
+# define SQLITE_OMIT_TRIGGER
+
# undef SQLITE_OMIT_VIRTUALTABLE
# define SQLITE_OMIT_VIRTUALTABLE
+
+# undef SQLITE_OMIT_WINDOWFUNC
+# define SQLITE_OMIT_WINDOWFUNC
+
+ As of this writing (2024-07-25), such a build fails in various ways
+ for as-yet-unknown reasons.
*/
-# undef SQLITE_OMIT_JSON
-# define SQLITE_OMIT_JSON
+#endif
+
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_BARE_BONES)
+# define SQLITE_WASM_HAS_VTAB 1
+#else
+# define SQLITE_WASM_HAS_VTAB 0
#endif
#include <assert.h>
@@ -264,10 +242,6 @@
#undef INC__STRINGIFY
#undef SQLITE_C
-#if defined(__EMSCRIPTEN__)
-# include <emscripten/console.h>
-#endif
-
#if 0
/*
** An EXPERIMENT in implementing a stack-based allocator analog to
@@ -412,7 +386,7 @@ int sqlite3__wasm_db_error(sqlite3*db, int err_code, const char *zMsg){
return err_code;
}
-#if SQLITE_WASM_TESTS
+#if SQLITE_WASM_ENABLE_C_TESTS
struct WasmTestStruct {
int v4;
void * ppV;
@@ -432,7 +406,7 @@ void sqlite3__wasm_test_struct(WasmTestStruct * s){
}
return;
}
-#endif /* SQLITE_WASM_TESTS */
+#endif /* SQLITE_WASM_ENABLE_C_TESTS */
/*
** This function is NOT part of the sqlite3 public API. It is strictly
@@ -967,7 +941,7 @@ const char * sqlite3__wasm_enum_json(void){
} _DefGroup;
DefGroup(vtab) {
-#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL)
+#if SQLITE_WASM_HAS_VTAB
DefInt(SQLITE_INDEX_SCAN_UNIQUE);
DefInt(SQLITE_INDEX_CONSTRAINT_EQ);
DefInt(SQLITE_INDEX_CONSTRAINT_GT);
@@ -995,7 +969,7 @@ const char * sqlite3__wasm_enum_json(void){
DefInt(SQLITE_FAIL);
//DefInt(SQLITE_ABORT); // Also an error code
DefInt(SQLITE_REPLACE);
-#endif /*!SQLITE_OMIT_VIRTUALTABLE*/
+#endif /*SQLITE_WASM_HAS_VTAB*/
} _DefGroup;
#undef DefGroup
@@ -1110,6 +1084,7 @@ const char * sqlite3__wasm_enum_json(void){
#undef CurrentStruct
+#if SQLITE_WASM_HAS_VTAB
#define CurrentStruct sqlite3_vtab
StructBinder {
M(pModule, "p");
@@ -1155,7 +1130,6 @@ const char * sqlite3__wasm_enum_json(void){
} _StructBinder;
#undef CurrentStruct
-#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL)
/**
** Workaround: in order to map the various inner structs from
** sqlite3_index_info, we have to uplift those into constructs we
@@ -1232,9 +1206,9 @@ const char * sqlite3__wasm_enum_json(void){
} _StructBinder;
#undef CurrentStruct
-#endif /*!SQLITE_OMIT_VIRTUALTABLE*/
+#endif /*SQLITE_WASM_HAS_VTAB*/
-#if SQLITE_WASM_TESTS
+#if SQLITE_WASM_ENABLE_C_TESTS
#define CurrentStruct WasmTestStruct
StructBinder {
M(v4, "i");
@@ -1244,7 +1218,7 @@ const char * sqlite3__wasm_enum_json(void){
M(xFunc, "v(p)");
} _StructBinder;
#undef CurrentStruct
-#endif
+#endif /*SQLITE_WASM_ENABLE_C_TESTS*/
} out( "]"/*structs*/);
@@ -1603,7 +1577,7 @@ sqlite3_kvvfs_methods * sqlite3__wasm_kvvfs_methods(void){
return &sqlite3KvvfsMethods;
}
-#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL)
+#if SQLITE_WASM_HAS_VTAB
/*
** This function is NOT part of the sqlite3 public API. It is strictly
** for use by the sqlite project's own JS/WASM bindings.
@@ -1626,7 +1600,7 @@ int sqlite3__wasm_vtab_config(sqlite3 *pDb, int op, int arg){
return SQLITE_MISUSE;
}
}
-#endif /*!SQLITE_OMIT_VIRTUALTABLE*/
+#endif /*SQLITE_WASM_HAS_VTAB*/
/*
** This function is NOT part of the sqlite3 public API. It is strictly
@@ -1750,6 +1724,7 @@ char * sqlite3__wasm_qfmt_token(char *z, int addQuotes){
}
#if defined(__EMSCRIPTEN__) && defined(SQLITE_ENABLE_WASMFS)
+#include <emscripten/console.h>
#include <emscripten/wasmfs.h>
/*
@@ -1801,7 +1776,7 @@ int sqlite3__wasm_init_wasmfs(const char *zUnused){
}
#endif /* __EMSCRIPTEN__ && SQLITE_ENABLE_WASMFS */
-#if SQLITE_WASM_TESTS
+#if SQLITE_WASM_ENABLE_C_TESTS
SQLITE_WASM_EXPORT
int sqlite3__wasm_test_intptr(int * p){
@@ -1967,6 +1942,9 @@ int sqlite3__wasm_SQLTester_strglob(const char *zGlob, const char *z){
return !sqlite3__wasm_SQLTester_strnotglob(zGlob, z);
}
-#endif /* SQLITE_WASM_TESTS */
+#endif /* SQLITE_WASM_ENABLE_C_TESTS */
#undef SQLITE_WASM_EXPORT
+#undef SQLITE_WASM_HAS_VTAB
+#undef SQLITE_WASM_BARE_BONES
+#undef SQLITE_WASM_ENABLE_C_TESTS