Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqlite): reset the statement when fetch_many() stream is dropped #1156

Merged
merged 1 commit into from
Apr 9, 2021
Merged

fix(sqlite): reset the statement when fetch_many() stream is dropped #1156

merged 1 commit into from
Apr 9, 2021

Conversation

link2xt
Copy link
Contributor

@link2xt link2xt commented Apr 6, 2021

Unlike Executor.fetch_optional(), Executor.fetch_many() does not
have a single exit. The stream can be dropped at any time. To catch
this event, we create a StatementResetter structure inside the stream
loop and reset the statement when it is dropped.

A test case it_resets_prepared_statement_after_fetch_many is
similar to it_resets_prepared_statement_after_fetch_one which tests
Executor.fetch_optional().

Fixes #1147

@link2xt link2xt marked this pull request as draft April 6, 2021 20:19
@link2xt link2xt marked this pull request as ready for review April 6, 2021 20:31
tests/sqlite/sqlite.rs Outdated Show resolved Hide resolved
@link2xt link2xt changed the title sqlite: reset the statement when fetch_many() stream is dropped fix(sqlite): reset the statement when fetch_many() stream is dropped Apr 8, 2021
Unlike `Executor.fetch_optional()`, `Executor.fetch_many()` does not
have a single exit.  The stream can be dropped at any time.  To catch
this event, we create a `StatementResetter` structure inside the stream
loop and reset the statement when it is dropped.

A test case `it_resets_prepared_statement_after_fetch_many` is
similar to `it_resets_prepared_statement_after_fetch_one` which tests
`Executor.fetch_optional()`.
@mehcode
Copy link
Member

mehcode commented Apr 9, 2021

Nice fix! Thank you for the contribution.

@mehcode mehcode merged commit 78656eb into launchbadge:master Apr 9, 2021
@link2xt link2xt deleted the sqlite3-reset-fetch_many branch April 9, 2021 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sqlite: dropping fetch result without reading to the end breaks connection
4 participants