1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

wasm minimal build: strip authorizers and JSON support (saves approx 35kb). Strip vtab support from the JS bits but cannot yet strip it from the C bits because that requires a custom-configured sqlite3.c.

FossilOrigin-Name: eb64d106551718467e0f6c6b53695410bf4c566901008e4cda8580d0f7efa7b0
This commit is contained in:
stephan
2024-07-24 23:58:28 +00:00
parent fe225745fc
commit b16c2980b3
10 changed files with 153 additions and 81 deletions

View File

@ -129,22 +129,6 @@
# define SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
#endif
/*
** If SQLITE_WASM_MINIMAL 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
#endif
/**********************************************************************/
/* SQLITE_O... */
#ifndef SQLITE_OMIT_DEPRECATED
@ -188,6 +172,48 @@
# define SQLITE_EXTRA_INIT sqlite3_wasm_extra_init
#endif
/*
** If SQLITE_WASM_MINIMAL 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
# define SQLITE_OMIT_AUTHORIZATION
/*Reminder re. custom sqlite3.c:
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
# undef SQLITE_OMIT_EXPLAIN
# define SQLITE_OMIT_EXPLAIN
*/
/*Requires a custom sqlite3.c
# undef SQLITE_OMIT_VIRTUALTABLE
# define SQLITE_OMIT_VIRTUALTABLE
*/
# undef SQLITE_OMIT_JSON
# define SQLITE_OMIT_JSON
#endif
#include <assert.h>
/*
@ -941,6 +967,7 @@ const char * sqlite3__wasm_enum_json(void){
} _DefGroup;
DefGroup(vtab) {
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL)
DefInt(SQLITE_INDEX_SCAN_UNIQUE);
DefInt(SQLITE_INDEX_CONSTRAINT_EQ);
DefInt(SQLITE_INDEX_CONSTRAINT_GT);
@ -968,6 +995,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*/
} _DefGroup;
#undef DefGroup
@ -1127,6 +1155,7 @@ 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
@ -1203,6 +1232,8 @@ const char * sqlite3__wasm_enum_json(void){
} _StructBinder;
#undef CurrentStruct
#endif /*!SQLITE_OMIT_VIRTUALTABLE*/
#if SQLITE_WASM_TESTS
#define CurrentStruct WasmTestStruct
StructBinder {
@ -1572,6 +1603,7 @@ sqlite3_kvvfs_methods * sqlite3__wasm_kvvfs_methods(void){
return &sqlite3KvvfsMethods;
}
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_MINIMAL)
/*
** This function is NOT part of the sqlite3 public API. It is strictly
** for use by the sqlite project's own JS/WASM bindings.
@ -1594,6 +1626,7 @@ int sqlite3__wasm_vtab_config(sqlite3 *pDb, int op, int arg){
return SQLITE_MISUSE;
}
}
#endif /*!SQLITE_OMIT_VIRTUALTABLE*/
/*
** This function is NOT part of the sqlite3 public API. It is strictly