You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] Restore DELIMITER state machine hangs on truncated stored-program dumps #360
src/lib/sql-import.ts:39-110 splitSqlStatements tracks delimiter state. If dump contains DELIMITER // followed by stored program body, then DELIMITER ; is missing (truncated file), state machine keeps custom delimiter and waits forever — no progress, no error, hang. Quoted identifier containing the word DELIMITER shifts state incorrectly.
Files
src/lib/sql-import.ts:39-110
Repro
Create dump: DELIMITER // followed by CREATE PROCEDURE body, no terminating DELIMITER ;
Attempt restore
Observe hang
Expected
Clear error: "restore incomplete, last statement truncated" rather than hang.
Proposed fix
S: guard DELIMITER recognition — only match when begins at column 1 AND followed by whitespace + non-quote char. Reset delimiter to ; on any unhandled EOF.
Acceptance
Stored-program dump from mysqldump --routines restores cleanly; truncated version produces clear error rather than hanging.
Fixed in #652, and the splitter moved out of the renderer entirely.
The state machine now lives in mas-core::restore, is fed the file in chunks as it is read, and finish() reports what the file ended in the middle of:
a quoted string
a quoted identifier
a /* */ comment
a stored program whose DELIMITER was never restored — your case
Each is an error naming the tail of the file so the user can recognise which one it is, capped so a truncated 100 MB INSERT does not quote a megabyte back at them. Previously the loop just kept accumulating and the restore made no progress and raised nothing.
Your second observation — "a quoted identifier containing the word DELIMITER shifts state incorrectly" — was the same shape and is fixed by the same rule you proposed: DELIMITER is recognised only at the start of a statement and only when whitespace follows it, so SELECT delimiter FROM t no longer changes the terminator for the rest of the file. There is a test for it.
A dump from mysqldump --routines restores cleanly (test: a_stored_program_restores_whole), and the truncated version reports rather than hanging (a_truncated_stored_program_reports_rather_than_hanging), which is your acceptance criterion exactly. It also reports that the statements before the truncation did apply, which is what a user needs before running the file again.
Activity
feat(backup): stream the dump and the restore, in the backend (#652)
EVWorth commentedon Sep 12, 2026
Fixed in #652, and the splitter moved out of the renderer entirely.
The state machine now lives in
mas-core::restore, is fed the file in chunks as it is read, andfinish()reports what the file ended in the middle of:/* */commentDELIMITERwas never restored — your caseEach is an error naming the tail of the file so the user can recognise which one it is, capped so a truncated 100 MB INSERT does not quote a megabyte back at them. Previously the loop just kept accumulating and the restore made no progress and raised nothing.
Your second observation — "a quoted identifier containing the word DELIMITER shifts state incorrectly" — was the same shape and is fixed by the same rule you proposed:
DELIMITERis recognised only at the start of a statement and only when whitespace follows it, soSELECT delimiter FROM tno longer changes the terminator for the rest of the file. There is a test for it.A dump from
mysqldump --routinesrestores cleanly (test:a_stored_program_restores_whole), and the truncated version reports rather than hanging (a_truncated_stored_program_reports_rather_than_hanging), which is your acceptance criterion exactly. It also reports that the statements before the truncation did apply, which is what a user needs before running the file again.