Repository navigation
refactor(import): run a SQL file through the streaming restore - #654
Merged
Merged
Conversation
SQL import and restore were the same operation with two implementations. The import one read the whole file into the renderer, split it there and sent back one statement per call — each on whichever pooled connection it landed on, so a `USE` or a session setting did not carry, and the file was capped at what the WebView could hold. It now calls `restore_database`: the backend reads the file in chunks, splits it in Rust and runs the statements on one connection, with the foreign-key checks off and a transaction that is honest about its reach. The dialog reads only the first 512 KB, to draw the preview and to name what the file will drop — and says so when the scan did not reach the end, rather than reporting "3 statements" for a two-gigabyte dump. The summary now says whether what already ran survives: MySQL commits before every CREATE, DROP and ALTER, so "stopped at statement 12" means different things depending on what came before it. A progress subscription that cannot attach no longer stops the work. It meant the bar does not move, and refusing to run the import over that was the wrong trade — all three dialogs now go ahead without it.
This was referenced Sep 12, 2026
Closed
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.
Closes #367, #578 — and removes the second implementation of a thing the backup work had just built properly.
SQL import and restore were the same operation, twice
The import one read the whole file into the renderer, split it there, and sent back one statement per call — each on whichever pooled connection it landed on, so a
USEor a session setting did not carry to the next, and the file was capped at what the WebView can hold. That is exactly what #359 and #358 were about on the restore side.It now calls
restore_database. The backend reads in chunks, splits in Rust (quotes, comments, DELIMITER), and runs on one connection with the foreign-key checks off and a transaction that is honest about its reach.The dialog reads only the first 512 KB — enough to preview the file and name what it will drop — and says so when the scan did not reach the end, instead of reporting "3 statements detected" for a two-gigabyte dump.
The summary now distinguishes the two outcomes that matter: "stopped at statement 12, rolled back — the database is as it was" and "stopped at statement 12; what already ran stands, because MySQL commits before every CREATE, DROP or ALTER".
#367 was already built; the remaining half is rejected
The destructive-statement warning exists: the preview counts them up front and lists the first five. This PR extends it to say when only part of the file was scanned.
Not doing the "require typing import to confirm" half. That gesture belongs to actions with no other guard and no undo — deleting a GitHub repo. Here there are already two: the amber list naming the statements, and the production gate, which raises its own dialog on a production connection. A third, typed, on every import would be trained away within a week and would make the two that matter easier to click through.
#578 was already fixed
parseCSVLinekeeps whether a field was quoted, andgenerateBatchInsertuses it:,,becomes NULL and,"",stays''. That ismysqlimport's convention and the one the issue proposed. No option is exposed, deliberately — the issue's own framing was "a choice the file cannot express", and the file can now express it.Also
A progress subscription that cannot attach no longer stops the work — it means the bar does not move, and refusing to run over that was the wrong trade. All three dialogs (backup, restore, import) go ahead without it.
2703 unit, 344 browser, clean.