SQLITE_FCNTL_SYNC.

This commit is contained in:
Nuno Cruces
2025-01-14 10:05:54 +00:00
parent ccb3dcd097
commit 8887036c20
2 changed files with 19 additions and 4 deletions

View File

@@ -121,6 +121,15 @@ type FileOverwrite interface {
Overwrite() error
}
// FileSync extends File to implement the
// SQLITE_FCNTL_SYNC file control opcode.
//
// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsync
type FileSync interface {
File
SyncSuper(super string) error
}
// FileCommitPhaseTwo extends File to implement the
// SQLITE_FCNTL_COMMIT_PHASETWO file control opcode.
//

View File

@@ -309,6 +309,16 @@ func vfsFileControlImpl(ctx context.Context, mod api.Module, file File, op _Fcnt
return vfsErrorCode(err, _IOERR)
}
case _FCNTL_SYNC:
if file, ok := file.(FileSync); ok {
var name string
if pArg != 0 {
name = util.ReadString(mod, pArg, _MAX_PATHNAME)
}
err := file.SyncSuper(name)
return vfsErrorCode(err, _IOERR)
}
case _FCNTL_COMMIT_PHASETWO:
if file, ok := file.(FileCommitPhaseTwo); ok {
err := file.CommitPhaseTwo()
@@ -384,10 +394,6 @@ func vfsFileControlImpl(ctx context.Context, mod api.Module, file File, op _Fcnt
}
}
// Consider also implementing these opcodes (in use by SQLite):
// _FCNTL_BUSYHANDLER
// _FCNTL_LAST_ERRNO
// _FCNTL_SYNC
return _NOTFOUND
}