diff --git a/conn.go b/conn.go index 3bf0216..43ae40d 100644 --- a/conn.go +++ b/conn.go @@ -69,6 +69,7 @@ func (c *Conn) openDB(filename string, flags OpenFlag) (uint32, error) { connPtr := c.arena.new(ptrlen) namePtr := c.arena.string(filename) + flags |= OPEN_EXRESCODE r := c.call(c.api.open, uint64(namePtr), uint64(connPtr), uint64(flags), 0) handle := c.mem.readUint32(connPtr) diff --git a/embed/build.sh b/embed/build.sh index 73ed0d0..29b0830 100755 --- a/embed/build.sh +++ b/embed/build.sh @@ -13,4 +13,10 @@ zig cc --target=wasm32-wasi -flto -g0 -Os \ -mbulk-memory -mreference-types \ -mnontrapping-fptoint -msign-ext \ -D_HAVE_SQLITE_CONFIG_H \ - $(awk '{print "-Wl,--export="$0}' exports.txt) \ No newline at end of file + $(awk '{print "-Wl,--export="$0}' exports.txt) + +# optimize SQLite +if which wasm-opt; then + wasm-opt -g -O -o sqlite3.tmp sqlite3.wasm + mv sqlite3.tmp sqlite3.wasm +fi \ No newline at end of file diff --git a/embed/exports.txt b/embed/exports.txt index 69b5b18..f9d5d40 100644 --- a/embed/exports.txt +++ b/embed/exports.txt @@ -40,7 +40,6 @@ sqlite3_blob_reopen sqlite3_get_autocommit sqlite3_last_insert_rowid sqlite3_changes64 -sqlite3_unlock_notify sqlite3_backup_init sqlite3_backup_step sqlite3_backup_finish diff --git a/embed/sqlite3.wasm b/embed/sqlite3.wasm old mode 100755 new mode 100644 index 6f0c6cb..19c2556 Binary files a/embed/sqlite3.wasm and b/embed/sqlite3.wasm differ diff --git a/sqlite3/amalg.c b/sqlite3/amalg.c index d942bf3..37b1153 100644 --- a/sqlite3/amalg.c +++ b/sqlite3/amalg.c @@ -3,9 +3,8 @@ #include "main.c" #include "os.c" #include "qsort.c" -#include "time.c" - #include "sqlite3.c" +#include "time.c" sqlite3_destructor_type malloc_destructor = &free; size_t sqlite3_interrupt_offset = offsetof(sqlite3, u1.isInterrupted); \ No newline at end of file diff --git a/sqlite3/download.sh b/sqlite3/download.sh index 0951636..21e4042 100755 --- a/sqlite3/download.sh +++ b/sqlite3/download.sh @@ -4,7 +4,7 @@ set -eo pipefail cd -P -- "$(dirname -- "$0")" if [ ! -f "sqlite3.c" ]; then - url="https://sqlite.org/2023/sqlite-amalgamation-3410000.zip" + url="https://sqlite.org/2023/sqlite-amalgamation-3410100.zip" curl "$url" > sqlite.zip unzip -d . sqlite.zip mv sqlite-amalgamation-*/sqlite3* . diff --git a/sqlite3/format.sh b/sqlite3/format.sh index 6b3a857..c65cbc6 100755 --- a/sqlite3/format.sh +++ b/sqlite3/format.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash cd -P -- "$(dirname -- "$0")" -clang-format -i \ - main.c \ - os.c \ - qsort.c \ - amalg.c \ No newline at end of file +shopt -s extglob +clang-format -i !(sqlite3*).@(c|h) \ No newline at end of file diff --git a/tests/mptest/testdata/build.sh b/tests/mptest/testdata/build.sh index e221442..3ceb8d5 100755 --- a/tests/mptest/testdata/build.sh +++ b/tests/mptest/testdata/build.sh @@ -23,4 +23,9 @@ zig cc --target=wasm32-wasi -flto -g0 -Os \ -DSQLITE_DEFAULT_LOCKING_MODE=0 \ -DHAVE_USLEEP -DSQLITE_NO_SYNC \ -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \ - -D_WASI_EMULATED_GETPID -lwasi-emulated-getpid \ No newline at end of file + -D_WASI_EMULATED_GETPID -lwasi-emulated-getpid + +if which wasm-opt; then + wasm-opt -g -O -o mptest.tmp mptest.wasm + mv mptest.tmp mptest.wasm +fi \ No newline at end of file diff --git a/tests/mptest/testdata/mptest.wasm b/tests/mptest/testdata/mptest.wasm old mode 100755 new mode 100644 index 97b7a68..33b5182 --- a/tests/mptest/testdata/mptest.wasm +++ b/tests/mptest/testdata/mptest.wasm @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3960b873a7dab969a66f7859d491cec0dd4e6c0c9f83eab449fb15ec5ebdfd8f -size 1077281 +oid sha256:56ba9702a874d9ebf8a7eab2b39f7f74127931038fa8c9298b59120ae20a4653 +size 969013