File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
diesel/src/mysql/connection/stmt Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff 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 }
@@ -178,7 +185,19 @@ impl StatementUse<'_> {
178185 }
179186
180187 pub ( super ) fn populate_row_buffers ( & self , binds : & mut OutputBinds ) -> QueryResult < Option < ( ) > > {
181- let next_row_result = unsafe { ffi:: mysql_stmt_fetch ( self . inner . stmt . as_ptr ( ) ) } ;
188+ let next_row_result = unsafe {
189+ let prev_length = * ( * ( * self . inner . stmt . as_ptr ( ) ) . bind ) . length ;
190+ let result = ffi:: mysql_stmt_fetch ( self . inner . stmt . as_ptr ( ) ) ;
191+
192+ // HACK: Newer libmariadb versions initialise length to 0 for fixed-size
193+ // types. Restore length to previous value if this is the case.
194+ if * ( * ( * self . inner . stmt . as_ptr ( ) ) . bind ) . length == 0 {
195+ * ( * ( * self . inner . stmt . as_ptr ( ) ) . bind ) . length = prev_length;
196+ }
197+
198+ result
199+ } ;
200+
182201 if next_row_result < 0 {
183202 self . inner . did_an_error_occur ( ) . map ( Some )
184203 } else {
You can’t perform that action at this time.
0 commit comments