Skip to content

Commit

Permalink
SQLITE_FCNTL_PDB.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Jan 13, 2025
1 parent a9f33cc commit ccb3dcd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions internal/util/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/ncruces/go-sqlite3/internal/alloc"
)

type ConnKey struct{}

type moduleKey struct{}
type moduleState struct {
mmapState
Expand Down
5 changes: 5 additions & 0 deletions vfs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 6 additions & 0 deletions vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ccb3dcd

Please sign in to comment.