Repository navigation
fix(core): make a new database file only where nothing is - #4316
Merged
Merged
Conversation
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.
Summary
FileOpenMode::CreateNewreports a file there as the newdriver.file_exists(DriverError::FileExists).create_new(O_EXCL). DuckDB builds beside the path as before, then hard links it into place, which fails on anything there; a file system without links gets a copy through an exclusivecreate_newhandle.FileOpenMode::Replace(FileEndpoint::replace), same behavior as before.File.Existsbefore the create.driver.file_existsopens the file as it is, as the form does for a file there when it was named (and as macOS does).Replaceonly for a file there when the save chooser closed, since the chooser asked about it. A free name sendsCreateNew, and a file made there before Connect is kept, with a message. A successful Test of a new file turns the row to open that file, so Connect does not refuse it.createalready said the path must not exist.CreateNewnow useFileEndpoint::replace: the SQLite and DuckDBopen_semanticstests and the DuckDBinstanceandcreate_filetests.Test plan
a_file_made_after_the_path_was_checked_is_never_replacedkeeps the file and its journal or log, with nothing left beside them. Also a free path, a stale log, a symbolic link at the path, a missing folder, and DuckDB's copy for a file system without links.create_new_keeps_a_database_already_there(SQLite) anda_new_database_keeps_a_database_already_there(DuckDB).a_new_file_never_replaces_one_made_after_the_path_was_checked(SQLite and DuckDB):connect.driver,driver.file_exists, the path, the bytes kept.AFileMadeAfterThePathWasCheckedIsNeverReplaced(DuckDB and SQLite).AFileMadeAfterTheNewNameWasChosenOpensAsItIs: names a free file, the sample appears there, Connect opens its tables.a_new_name_replaces_only_a_file_the_chooser_asked_about,a_tested_new_file_is_opened_by_connect,a_file_already_there_names_it_and_says_it_was_kept.