mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Commit phase-two API.
This commit is contained in:
@@ -81,6 +81,15 @@ type FilePowersafeOverwrite interface {
|
||||
SetPowersafeOverwrite(bool)
|
||||
}
|
||||
|
||||
// FilePowersafeOverwrite extends File to implement the
|
||||
// SQLITE_FCNTL_COMMIT_PHASETWO file control opcode.
|
||||
//
|
||||
// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html
|
||||
type FileCommitPhaseTwo interface {
|
||||
File
|
||||
CommitPhaseTwo() error
|
||||
}
|
||||
|
||||
// FileBatchAtomicWrite extends File to implement the
|
||||
// SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE
|
||||
// and SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE file control opcodes.
|
||||
|
||||
11
vfs/vfs.go
11
vfs/vfs.go
@@ -336,6 +336,12 @@ func vfsFileControl(ctx context.Context, mod api.Module, pFile uint32, op _Fcntl
|
||||
return vfsErrorCode(err, _IOERR_FSTAT)
|
||||
}
|
||||
|
||||
case _FCNTL_COMMIT_PHASETWO:
|
||||
if file, ok := file.(FileCommitPhaseTwo); ok {
|
||||
err := file.CommitPhaseTwo()
|
||||
return vfsErrorCode(err, _IOERR)
|
||||
}
|
||||
|
||||
case _FCNTL_BEGIN_ATOMIC_WRITE:
|
||||
if file, ok := file.(FileBatchAtomicWrite); ok {
|
||||
err := file.BeginAtomicWrite()
|
||||
@@ -356,9 +362,8 @@ func vfsFileControl(ctx context.Context, mod api.Module, pFile uint32, op _Fcntl
|
||||
// Consider also implementing these opcodes (in use by SQLite):
|
||||
// _FCNTL_PDB
|
||||
// _FCNTL_BUSYHANDLER
|
||||
// _FCNTL_CHUNK_SIZE
|
||||
// _FCNTL_COMMIT_PHASETWO
|
||||
// _FCNTL_OVERWRITE
|
||||
// _FCNTL_CHUNK_SIZE
|
||||
// _FCNTL_OVERWRITE
|
||||
// _FCNTL_PRAGMA
|
||||
// _FCNTL_SYNC
|
||||
return _NOTFOUND
|
||||
|
||||
Reference in New Issue
Block a user