Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

parse multiline when loading dump #355

Merged
merged 1 commit into from
Apr 26, 2023
Merged

parse multiline when loading dump #355

merged 1 commit into from
Apr 26, 2023

Conversation

glommer
Copy link
Contributor

@glommer glommer commented Apr 26, 2023

SQLite dumps are often multi-line, so accumulate on a buffer and only send when the line ends with ;

SQLite dumps are often multi-line, so accumulate on a buffer and only
send when the line ends with ;

Fixes libsql#354
Copy link
Contributor

@psarna psarna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure it won't work, rusqlite will only execute the first statement on execute(). You probably want to use execute_batch() instead, in line 97: https://docs.rs/rusqlite/latest/rusqlite/struct.Connection.html#method.execute_batch, which is syntactic sugar that lets you split statements. It only works for statements without params, but we're only using text statements here, so it will work.

And while at it, consider renaming line to something like statements? It's no longer a single line which makes the code rather confusing. curr is what's actually a single line of code in the new form.

@glommer
Copy link
Contributor Author

glommer commented Apr 26, 2023

there's only a single statement, @psarna.
I am not sending more than one statement per execute, I am buffering the statement in case it is multiline.

@psarna
Copy link
Contributor

psarna commented Apr 26, 2023

ah! My bad

@psarna
Copy link
Contributor

psarna commented Apr 26, 2023

Side note, are we sure the dumps always include at most 1 statement in the dump? Because current code would break on more than 1 in a single line, which is a preexisting issue

@glommer
Copy link
Contributor Author

glommer commented Apr 26, 2023

yes, we are. (sqlite generates them like that).
Although I was surprised to see multiline already anyway

@psarna
Copy link
Contributor

psarna commented Apr 26, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Apr 26, 2023

Build succeeded:

@bors bors bot merged commit 6d7ffb3 into libsql:main Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants