Open a database with configuration, and so read-only - #39
Closed
calvinchengx wants to merge 10 commits into
Closed
calvinchengx wants to merge 10 commits into
calvinchengx wants to merge 10 commits into
Conversation
duckdb_open takes no configuration, so there was no way to ask for a read-only database. A process whose only job is to read should not be able to write by accident, and asking the engine to enforce that is worth more than intending it. Options arrive as a DSN query string and go through duckdb_open_ext. The last ? separates, so a path containing one is still openable, and a path with no ? takes the original code path unchanged.
Contributor
Author
|
Already on main: this branch has 0 commits main does not have and an empty diff against it. Closing as landed, not as rejected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
duckdb_opentakes no configuration, so there is currently no way to open a database read-only through this driver. A process whose only job is to read should not be able to write by accident, and asking the engine to enforce that is worth more than intending it.Options arrive as a DSN query string and go through
duckdb_open_ext:Three details worth a look:
?takes the originalduckdb_openpath unchanged, so nothing existing changes behaviour.?separates, not the first. A DuckDB path may legitimately contain one, and taking the first would make such a file unopenable throughdatabase/sqlwith no way to say otherwise.duckdb_open_extreports through a caller-ownedchar*, freed withduckdb_free.NewDuckDBWithSettings(path, settings)is the direct form;NewDuckDB(path)is unchanged and delegates to it.Tests cover the DSN split (including the awkward paths), and there is one that writes to a database, reopens it read-only, reads successfully, and checks the write is refused — so the flag is proven to reach DuckDB rather than merely be passed to it.