Skip to content

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

Merged
mehcode merged 1 commit into
transact-rs:masterfrom
link2xt:sqlite3-reset-fetch_many
Apr 9, 2021
Merged

mehcode merged 1 commit into
transact-rs:masterfrom
link2xt:sqlite3-reset-fetch_many

Conversation

@link2xt

@link2xt link2xt commented Apr 6, 2021

Copy link
Copy Markdown
Contributor

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
Comment thread tests/sqlite/sqlite.rs 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

mehcode commented Apr 9, 2021

Copy link
Copy Markdown
Contributor

Nice fix! Thank you for the contribution.

@mehcode
mehcode merged commit 78656eb into transact-rs: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