Skip to content

sqlite: use Arc<> around StatementHandle instead of Copying it - #1186

Closed
link2xt wants to merge 2 commits into
transact-rs:masterfrom
deltachat:sqlite-arc
Closed

link2xt wants to merge 2 commits into
transact-rs:masterfrom
deltachat:sqlite-arc

Conversation

@link2xt

@link2xt link2xt commented Apr 23, 2021

Copy link
Copy Markdown
Contributor

No description provided.

link2xt added 2 commits April 23, 2021 00:00
This guarantees that StatementHandle is never used after calling
`sqlite3_finalize`. Now `sqlite3_finalize` is only called when
StatementHandle is dropped.
Otherwise some tests fail to close connection.
@link2xt

link2xt commented Apr 23, 2021

Copy link
Copy Markdown
Contributor Author

This is an attempt to fix persistent segfaults in sqlite3_step: chatmail/core#2378 (comment)

Comment on lines +38 to +43
let resp = match status {
SQLITE_ROW => Ok(Either::Right(())),
SQLITE_DONE => Ok(Either::Left(statement.changes())),
_ => Err(statement.last_error().into()),
};
resp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let resp = match status {
SQLITE_ROW => Ok(Either::Right(())),
SQLITE_DONE => Ok(Either::Left(statement.changes())),
_ => Err(statement.last_error().into()),
};
resp
match status {
SQLITE_ROW => Ok(Either::Right(())),
SQLITE_DONE => Ok(Either::Left(statement.changes())),
_ => Err(statement.last_error().into()),
}

resp
} else {
// Statement is already finalized.
Err(Error::WorkerCrashed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Strictly speaking, the worker didn't actually crash here. I'd consider a different error variant, maybe even a new one if none of the existing fit.

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.

2 participants