add URI parameter support via optional URIOpener interface - #18
Conversation
Replace the internal sqlite3vfs fork with the upstream module import and a temporary replace to the URI-support branch from psanford/sqlite3vfs#18. Add an end-to-end URI replica_url test and keep test fault injection active for FilenameOpener-based opens.
|
I am fine with doing this conceptually, but this pr is a bit of a mess. It looks like you asked claude-code to implement this and threw a pr up with no real thought about it. A reasonable interface would probably look more like: If you are going to use claude-code at least use a new session to critique the pr before you submit it. |
a9ece85 to
bcabaf2
Compare
|
Thanks for the feedback. I reworked this around the narrower |
bcabaf2 to
583d6e6
Compare
|
Hi @psanford just following up to get your thoughts on this last change? Thanks again for all your work on this repo! |
Switches the pseudo-version pin to the tagged v0.1.0 release on corylanou/sqlite3vfs so the dependency remains reachable if the uri-filename-support branch is deleted (e.g. when psanford/sqlite3vfs#18 lands upstream and the source branch is cleaned up). When the upstream PR merges, drop the replace directive and update the require to the upstream tag/pseudo-version.
Replace the internal sqlite3vfs fork with the upstream module import and a temporary replace to the URI-support branch from psanford/sqlite3vfs#18. Add an end-to-end URI replica_url test and keep test fault injection active for FilenameOpener-based opens.
Switches the pseudo-version pin to the tagged v0.1.0 release on corylanou/sqlite3vfs so the dependency remains reachable if the uri-filename-support branch is deleted (e.g. when psanford/sqlite3vfs#18 lands upstream and the source branch is cleaned up). When the upstream PR merges, drop the replace directive and update the require to the upstream tag/pseudo-version.
|
Thanks for fixing this up! |
Replace the internal sqlite3vfs fork with the upstream module import and a temporary replace to the URI-support branch from psanford/sqlite3vfs#18. Add an end-to-end URI replica_url test and keep test fault injection active for FilenameOpener-based opens.
Switches the pseudo-version pin to the tagged v0.1.0 release on corylanou/sqlite3vfs so the dependency remains reachable if the uri-filename-support branch is deleted (e.g. when psanford/sqlite3vfs#18 lands upstream and the source branch is cleaned up). When the upstream PR merges, drop the replace directive and update the require to the upstream tag/pseudo-version.
Replace the internal sqlite3vfs fork with the upstream module import and a temporary replace to the URI-support branch from psanford/sqlite3vfs#18. Add an end-to-end URI replica_url test and keep test fault injection active for FilenameOpener-based opens.
Switches the pseudo-version pin to the tagged v0.1.0 release on corylanou/sqlite3vfs so the dependency remains reachable if the uri-filename-support branch is deleted (e.g. when psanford/sqlite3vfs#18 lands upstream and the source branch is cleaned up). When the upstream PR merges, drop the replace directive and update the require to the upstream tag/pseudo-version.
Motivation
Expose SQLite URI parameters to VFS implementations at open time.
I hit this while building Litestream as a SQLite loadable extension + VFS. When a user loads a VFS extension and opens a database with URI parameters, for example:
The VFS needs those params during
xOpento initialize the connection. Environment variables are process-wide, PRAGMAs run after open, and SQLite URI parameters are the per-connection mechanism available duringxOpen.Relevant downstream issues: benbjohnson/litestream#1150 and benbjohnson/litestream#1231.
Changes
Adds an optional interface:
When a registered VFS implements
URIOpener, the cgo bridge reads the URI parameters from SQLite's filename pointer usingsqlite3_uri_key()andsqlite3_uri_parameter(), then callsOpenURI. Existing VFS implementations continue to useOpenunchanged.defaultVFSv1forwardsOpenURIto wrapped VFS values that implementURIOpener, so callers can register a plainVFSthat optionally implements the URI-aware method.Tests
TestURIOpenerregisters a capturing VFS, opensfile:test.db?vfs=...&poll_interval=5s&cache_size=128, and verifies thatOpenURIreceives the filename and URI parameter map.Verified with:
go test -race ./...