diff --git a/.github/workflows/repro.yml b/.github/workflows/repro.yml index 80c5758..ac7a594 100644 --- a/.github/workflows/repro.yml +++ b/.github/workflows/repro.yml @@ -5,7 +5,10 @@ on: jobs: test: - runs-on: ubuntu-latest + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/embed/sqlite3.wasm b/embed/sqlite3.wasm index 2276261..b9568c1 100755 Binary files a/embed/sqlite3.wasm and b/embed/sqlite3.wasm differ diff --git a/gormlite/sqlite.go b/gormlite/sqlite.go index a5b0d69..453dbe7 100644 --- a/gormlite/sqlite.go +++ b/gormlite/sqlite.go @@ -13,7 +13,6 @@ import ( "gorm.io/gorm/migrator" "gorm.io/gorm/schema" - "github.com/ncruces/go-sqlite3" "github.com/ncruces/go-sqlite3/driver" ) @@ -40,9 +39,7 @@ func (dialector _Dialector) Initialize(db *gorm.DB) (err error) { if dialector.Conn != nil { db.ConnPool = dialector.Conn } else { - conn, err := driver.Open(dialector.DSN, func(c *sqlite3.Conn) error { - return c.Exec("PRAGMA foreign_keys = ON") - }) + conn, err := driver.Open(dialector.DSN, nil) if err != nil { return err } diff --git a/sqlite3/sqlite_cfg.h b/sqlite3/sqlite_cfg.h index 252755d..e3e746a 100644 --- a/sqlite3/sqlite_cfg.h +++ b/sqlite3/sqlite_cfg.h @@ -46,6 +46,8 @@ // Other Options #define SQLITE_ALLOW_URI_AUTHORITY +#define SQLITE_TRUSTED_SCHEMA 0 +#define SQLITE_DEFAULT_FOREIGN_KEYS 1 #define SQLITE_ENABLE_ATOMIC_WRITE #define SQLITE_ENABLE_BATCH_ATOMIC_WRITE @@ -55,6 +57,12 @@ // https://sqlite.org/wal.html#noshm #undef SQLITE_OMIT_WAL +// We have our own memdb VFS. +// To avoid interactions between the two, +// omit sqlite3_serialize/sqlite3_deserialize, +// which we also don't wrap. +#define SQLITE_OMIT_DESERIALIZE + // Amalgamated Extensions #define SQLITE_ENABLE_MATH_FUNCTIONS 1 diff --git a/sqlite3/vfs.c b/sqlite3/vfs.c index bb57faf..ca9dcff 100644 --- a/sqlite3/vfs.c +++ b/sqlite3/vfs.c @@ -10,7 +10,6 @@ int go_vfs_find(const char *zVfsName); int go_randomness(sqlite3_vfs *, int nByte, char *zOut); int go_sleep(sqlite3_vfs *, int microseconds); -int go_current_time(sqlite3_vfs *, double *); int go_current_time_64(sqlite3_vfs *, sqlite3_int64 *); int go_open(sqlite3_vfs *, sqlite3_filename zName, sqlite3_file *, int flags, @@ -78,7 +77,6 @@ int sqlite3_os_init() { .xRandomness = go_randomness, .xSleep = go_sleep, - .xCurrentTime = go_current_time, .xCurrentTimeInt64 = go_current_time_64, }; return sqlite3_vfs_register(&os_vfs, /*default=*/true); @@ -127,7 +125,6 @@ sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName) { .xRandomness = go_randomness, .xSleep = go_sleep, - .xCurrentTime = go_current_time, .xCurrentTimeInt64 = go_current_time_64, }; return go_vfs_list; diff --git a/vfs/tests/mptest/testdata/mptest.wasm.bz2 b/vfs/tests/mptest/testdata/mptest.wasm.bz2 index 36c930d..9e88528 100644 --- a/vfs/tests/mptest/testdata/mptest.wasm.bz2 +++ b/vfs/tests/mptest/testdata/mptest.wasm.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7480f2234302b68d205e8a4cb83074aeb25a91c5b1a15f27579eda9eb84f670 -size 513613 +oid sha256:0d3da66a99571be0305e1056471aea119c99eac0b6e1c2ad541cc1b73c6b316f +size 512268 diff --git a/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 b/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 index 8d6862b..bf24e33 100644 --- a/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 +++ b/vfs/tests/speedtest1/testdata/speedtest1.wasm.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e27252fbac7fdec8464722d84f65ced6e4916b720c39a0213ce0219c20610a63 -size 527531 +oid sha256:06597e30e635f164307ed8fd204f8d93013a7da845ab5cb1ca5db3b10ef010fb +size 526654 diff --git a/vfs/vfs.go b/vfs/vfs.go index 51bcb5b..820f4dc 100644 --- a/vfs/vfs.go +++ b/vfs/vfs.go @@ -23,7 +23,6 @@ func ExportHostFunctions(env wazero.HostModuleBuilder) wazero.HostModuleBuilder util.ExportFuncIIJ(env, "go_localtime", vfsLocaltime) util.ExportFuncIIII(env, "go_randomness", vfsRandomness) util.ExportFuncIII(env, "go_sleep", vfsSleep) - util.ExportFuncIII(env, "go_current_time", vfsCurrentTime) util.ExportFuncIII(env, "go_current_time_64", vfsCurrentTime64) util.ExportFuncIIIII(env, "go_full_pathname", vfsFullPathname) util.ExportFuncIIII(env, "go_delete", vfsDelete) @@ -84,12 +83,6 @@ func vfsSleep(ctx context.Context, mod api.Module, pVfs, nMicro uint32) _ErrorCo return _OK } -func vfsCurrentTime(ctx context.Context, mod api.Module, pVfs, prNow uint32) _ErrorCode { - day := julianday.Float(time.Now()) - util.WriteFloat64(mod, prNow, day) - return _OK -} - func vfsCurrentTime64(ctx context.Context, mod api.Module, pVfs, piNow uint32) _ErrorCode { day, nsec := julianday.Date(time.Now()) msec := day*86_400_000 + nsec/1_000_000 diff --git a/vfs/vfs_test.go b/vfs/vfs_test.go index 043488d..0729a62 100644 --- a/vfs/vfs_test.go +++ b/vfs/vfs_test.go @@ -85,22 +85,6 @@ func Test_vfsSleep(t *testing.T) { } } -func Test_vfsCurrentTime(t *testing.T) { - mod := wazerotest.NewModule(wazerotest.NewMemory(wazerotest.PageSize)) - ctx := context.TODO() - - now := time.Now() - rc := vfsCurrentTime(ctx, mod, 0, 4) - if rc != 0 { - t.Fatal("returned", rc) - } - - want := julianday.Float(now) - if got := util.ReadFloat64(mod, 4); float32(got) != float32(want) { - t.Errorf("got %v, want %v", got, want) - } -} - func Test_vfsCurrentTime64(t *testing.T) { mod := wazerotest.NewModule(wazerotest.NewMemory(wazerotest.PageSize)) ctx := context.TODO()