Skip to content

Commit f791705

Browse files
author
simonz
committed
fix(mysql): restore bind buffer length for newer mariadb versions
1 parent 143b254 commit f791705

File tree

1 file changed

+7
-0
lines changed
  • diesel/src/mysql/connection/stmt

1 file changed

+7
-0
lines changed

diesel/src/mysql/connection/stmt/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ impl Statement {
117117
/// you must call this function again before calling `mysql_stmt_fetch`.
118118
pub unsafe fn bind_result(&self, binds: *mut ffi::MYSQL_BIND) -> QueryResult<()> {
119119
unsafe {
120+
let prev_length = *(*binds).length;
120121
ffi::mysql_stmt_bind_result(self.stmt.as_ptr(), binds);
122+
123+
// HACK: Newer libmariadb versions initialise length to 0 for fixed-size
124+
// types. Restore length to previous value if this is the case.
125+
if *(*binds).length == 0 {
126+
*(*binds).length = prev_length;
127+
}
121128
}
122129
self.did_an_error_occur()
123130
}

0 commit comments

Comments
 (0)