SQLITE_FCNTL_PDB.

This commit is contained in:
Nuno Cruces
2025-01-13 13:45:41 +00:00
parent a9f33cc2b0
commit ccb3dcd097
4 changed files with 14 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ func OpenFlags(filename string, flags OpenFlag) (*Conn, error) {
return newConn(context.Background(), filename, flags)
}
type connKey struct{}
type connKey = util.ConnKey
func newConn(ctx context.Context, filename string, flags OpenFlag) (res *Conn, _ error) {
err := ctx.Err()

View File

@@ -8,6 +8,8 @@ import (
"github.com/ncruces/go-sqlite3/internal/alloc"
)
type ConnKey struct{}
type moduleKey struct{}
type moduleState struct {
mmapState

View File

@@ -191,3 +191,8 @@ type fileControl interface {
File
fileControl(ctx context.Context, mod api.Module, op _FcntlOpcode, pArg uint32) _ErrorCode
}
type filePDB interface {
File
SetDB(any)
}

View File

@@ -376,6 +376,12 @@ func vfsFileControlImpl(ctx context.Context, mod api.Module, file File, op _Fcnt
return _OK
}
}
case _FCNTL_PDB:
if file, ok := file.(filePDB); ok {
file.SetDB(ctx.Value(util.ConnKey{}))
return _OK
}
}
// Consider also implementing these opcodes (in use by SQLite):