Skip to content

Commit 24c0435

Browse files
committed
Merge pull request diesel-rs#1847 from diesel-rs/sg-fix-mysql
Fix compatibility with MySQL 8.0
1 parent 61ea061 commit 24c0435

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All user visible changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/), as described
55
for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md)
66

7+
## Unreleased
8+
9+
### Fixed
10+
11+
* Fixed an issue that occurred with MySQL 8.0 when calling `.execute` or
12+
`.batch_execute` with a single query that returned a result set (such as our
13+
`SELECT 1` health check in `r2d2`).
14+
715
## [1.3.2] - 2018-06-13
816

917
### Fixed

diesel/src/mysql/connection/raw.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,10 @@ impl RawConnection {
152152
fn flush_pending_results(&self) -> QueryResult<()> {
153153
// We may have a result to process before advancing
154154
self.consume_current_result()?;
155-
while self.next_result()? {
155+
while self.more_results() {
156+
self.next_result()?;
156157
self.consume_current_result()?;
157158
}
158-
// next_result returns whether we've advanced to the *last* one, not
159-
// whether we're completely done.
160-
self.consume_current_result()?;
161159
Ok(())
162160
}
163161

@@ -171,12 +169,13 @@ impl RawConnection {
171169
self.did_an_error_occur()
172170
}
173171

174-
/// Calls `mysql_next_result` and returns whether there are more results
175-
/// after this one.
176-
fn next_result(&self) -> QueryResult<bool> {
177-
let more_results = unsafe { ffi::mysql_next_result(self.0.as_ptr()) == 0 };
178-
self.did_an_error_occur()?;
179-
Ok(more_results)
172+
fn more_results(&self) -> bool {
173+
unsafe { ffi::mysql_more_results(self.0.as_ptr()) != 0 }
174+
}
175+
176+
fn next_result(&self) -> QueryResult<()> {
177+
unsafe { ffi::mysql_next_result(self.0.as_ptr()) };
178+
self.did_an_error_occur()
180179
}
181180
}
182181

0 commit comments

Comments
 (0)