@@ -68,6 +68,13 @@ fn disconnect(mut conn: Conn) {
6868 }
6969}
7070
71+ #[ derive( Debug ) ]
72+ pub enum PendingResult {
73+ Text ( Arc < Vec < Column > > ) ,
74+ Binary ( Arc < Vec < Column > > , StmtCacheResult ) ,
75+ Empty ,
76+ }
77+
7178/// Mysql connection
7279struct ConnInner {
7380 stream : Option < Stream > ,
@@ -79,7 +86,7 @@ struct ConnInner {
7986 status : consts:: StatusFlags ,
8087 last_ok_packet : Option < OkPacket < ' static > > ,
8188 pool : Option < Pool > ,
82- has_result : Option < ( Arc < Vec < Column > > , Option < StmtCacheResult > ) > ,
89+ has_result : Option < PendingResult > ,
8390 in_transaction : bool ,
8491 opts : Opts ,
8592 last_io : Instant ,
@@ -521,13 +528,18 @@ impl Conn {
521528
522529 async fn drop_result ( mut self ) -> Result < Conn > {
523530 match self . inner . has_result . take ( ) {
524- Some ( ( columns, None ) ) => {
531+ Some ( PendingResult :: Text ( columns) ) => {
525532 query_result:: assemble :: < _ , TextProtocol > ( self , Some ( columns) , None )
526533 . drop_result ( )
527534 . await
528535 }
529- Some ( ( columns, cached) ) => {
530- query_result:: assemble :: < _ , BinaryProtocol > ( self , Some ( columns) , cached)
536+ Some ( PendingResult :: Binary ( columns, cached) ) => {
537+ query_result:: assemble :: < _ , BinaryProtocol > ( self , Some ( columns) , Some ( cached) )
538+ . drop_result ( )
539+ . await
540+ }
541+ Some ( PendingResult :: Empty ) => {
542+ query_result:: assemble :: < _ , TextProtocol > ( self , None , None )
531543 . drop_result ( )
532544 . await
533545 }
@@ -619,7 +631,7 @@ impl ConnectionLike for Conn {
619631 & self . inner . opts
620632 }
621633
622- fn get_pending_result ( & self ) -> Option < & ( Arc < Vec < Column > > , Option < StmtCacheResult > ) > {
634+ fn get_pending_result ( & self ) -> Option < & PendingResult > {
623635 self . inner . has_result . as_ref ( )
624636 }
625637
@@ -639,7 +651,7 @@ impl ConnectionLike for Conn {
639651 self . inner . in_transaction = in_transaction;
640652 }
641653
642- fn set_pending_result ( & mut self , meta : Option < ( Arc < Vec < Column > > , Option < StmtCacheResult > ) > ) {
654+ fn set_pending_result ( & mut self , meta : Option < PendingResult > ) {
643655 self . inner . has_result = meta;
644656 }
645657
@@ -1194,6 +1206,52 @@ mod test {
11941206 Ok ( ( ) )
11951207 }
11961208
1209+ #[ tokio:: test]
1210+ async fn issue_107 ( ) -> super :: Result < ( ) > {
1211+ let conn = Conn :: new ( get_opts ( ) ) . await ?;
1212+ let conn = conn
1213+ . drop_query (
1214+ r"CREATE TEMPORARY TABLE mysql.issue (
1215+ a BIGINT(20) UNSIGNED,
1216+ b VARBINARY(16),
1217+ c BINARY(32),
1218+ d BIGINT(20) UNSIGNED,
1219+ e BINARY(32)
1220+ )" ,
1221+ )
1222+ . await ?;
1223+ let conn = conn
1224+ . drop_query (
1225+ r"INSERT INTO mysql.issue VALUES (
1226+ 0,
1227+ 0xC066F966B0860000,
1228+ 0x7939DA98E524C5F969FC2DE8D905FD9501EBC6F20001B0A9C941E0BE6D50CF44,
1229+ 0,
1230+ ''
1231+ ), (
1232+ 1,
1233+ '',
1234+ 0x076311DF4D407B0854371BA13A5F3FB1A4555AC22B361375FD47B263F31822F2,
1235+ 0,
1236+ ''
1237+ )" ,
1238+ )
1239+ . await ?;
1240+
1241+ let q = "SELECT b, c, d, e FROM mysql.issue" ;
1242+ let result = conn. query ( q) . await ?;
1243+
1244+ let ( conn, loaded_structs) = result
1245+ . map_and_drop ( |row| crate :: from_row :: < ( Vec < u8 > , Vec < u8 > , u64 , Vec < u8 > ) > ( dbg ! ( row) ) )
1246+ . await ?;
1247+
1248+ conn. disconnect ( ) . await ?;
1249+
1250+ assert_eq ! ( loaded_structs. len( ) , 2 ) ;
1251+
1252+ Ok ( ( ) )
1253+ }
1254+
11971255 #[ tokio:: test]
11981256 async fn should_run_transactions ( ) -> super :: Result < ( ) > {
11991257 let conn = Conn :: new ( get_opts ( ) ) . await ?;
0 commit comments