From 5d5c302ff4514204d632bcbbc673cd12daeda3a5 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Sat, 4 May 2024 09:48:50 +0100 Subject: [PATCH] Support for z/OS. Support is behind sqlite3_flock build tag, and tested through s390x Linux. See #86. --- .github/workflows/test.yml | 3 +++ vfs/README.md | 4 ++++ vfs/lock_test.go | 6 +++--- vfs/os_darwin.go | 2 +- vfs/os_linux.go | 2 +- vfs/os_unix_test.go | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 656ea40..ca313f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -145,3 +145,6 @@ jobs: - name: Test riscv64 run: GOARCH=riscv64 go test -v -short ./... + + - name: Test s390x (like z/OS) + run: GOARCH=s390x go test -v -short -tags sqlite3_flock ./... \ No newline at end of file diff --git a/vfs/README.md b/vfs/README.md index 212ad6d..64b6e93 100644 --- a/vfs/README.md +++ b/vfs/README.md @@ -31,6 +31,10 @@ However, concurrency is reduced with BSD locks On Windows, this module uses `LockFileEx` and `UnlockFileEx`, like SQLite. +On Linux and z/OS, BSD locks are fully functional, +but incompatible with POSIX advisory locks (and SQLite). +You can opt into BSD locks with the `sqlite3_flock` build tag. + On all other platforms, file locking is not supported, and you must use [`nolock=1`](https://sqlite.org/uri.html#urinolock) (or [`immutable=1`](https://sqlite.org/uri.html#uriimmutable)) diff --git a/vfs/lock_test.go b/vfs/lock_test.go index 72ce24a..7f338b1 100644 --- a/vfs/lock_test.go +++ b/vfs/lock_test.go @@ -105,7 +105,7 @@ func Test_vfsLock(t *testing.T) { t.Fatal("returned", rc) } if got := util.ReadUint32(mod, pOutput); got == 0 { - t.Error("file wasn't locked") + t.Log("file wasn't locked, locking is incompatible with SQLite") } rc = vfsCheckReservedLock(ctx, mod, pFile2, pOutput) if rc != _OK { @@ -132,7 +132,7 @@ func Test_vfsLock(t *testing.T) { t.Fatal("returned", rc) } if got := util.ReadUint32(mod, pOutput); got == 0 { - t.Error("file wasn't locked") + t.Log("file wasn't locked, locking is incompatible with SQLite") } rc = vfsCheckReservedLock(ctx, mod, pFile2, pOutput) if rc != _OK { @@ -159,7 +159,7 @@ func Test_vfsLock(t *testing.T) { t.Fatal("returned", rc) } if got := util.ReadUint32(mod, pOutput); got == 0 { - t.Error("file wasn't locked") + t.Log("file wasn't locked, locking is incompatible with SQLite") } rc = vfsCheckReservedLock(ctx, mod, pFile2, pOutput) if rc != _OK { diff --git a/vfs/os_darwin.go b/vfs/os_darwin.go index 9826eb2..8bfe96b 100644 --- a/vfs/os_darwin.go +++ b/vfs/os_darwin.go @@ -1,4 +1,4 @@ -//go:build !sqlite3_flock && !sqlite3_nosys +//go:build !(sqlite3_flock || sqlite3_nosys) package vfs diff --git a/vfs/os_linux.go b/vfs/os_linux.go index 8a43f43..11e683a 100644 --- a/vfs/os_linux.go +++ b/vfs/os_linux.go @@ -1,4 +1,4 @@ -//go:build !sqlite3_nosys +//go:build !(sqlite3_flock || sqlite3_nosys) package vfs diff --git a/vfs/os_unix_test.go b/vfs/os_unix_test.go index bf2de34..ad430ab 100644 --- a/vfs/os_unix_test.go +++ b/vfs/os_unix_test.go @@ -1,4 +1,4 @@ -//go:build unix && !sqlite3_flock && !sqlite3_nosys +//go:build unix && !(sqlite3_flock || sqlite3_nosys) package vfs