mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
SQLITE_FCNTL_SYNC.
This commit is contained in:
@@ -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.
|
||||
//
|
||||
|
||||
14
vfs/vfs.go
14
vfs/vfs.go
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user