Repository: blackbeam/rust-mysql-simple (language: rust)

Issue:
Incompatible version of MySQL Async and MySQL Simple
My App uses mysql-async in the core functions and tests we use mysql-simple to execute tests.
Currently the version of mysql-async uses mysql_common v0.31 and mysql-simple uses mysql_common v0.30 which causes some errors due to two versions of mysql_common been used:

```
error[E0308]: `?` operator has incompatible types
   --> app-mysql/tests/vertical.rs:596:82
    |
596 |                 .exec::<mysql_async::Row, _, _>(query, mysql::Params::Positional(to_values(key)?))
    |                                                                                  ^^^^^^^^^^^^^^^ expected `mysql::Value`, found `mysql_async::Value`
    |
    = note: `?` operator cannot convert from `std::vec::Vec<mysql_async::Value>` to `std::vec::Vec<mysql::Value>`
    = note: `mysql_async::Value` and `mysql::Value` have similar names, but are actually distinct types
note: `mysql_async::Value` is defined in crate `mysql_common`
   --> /Users/marcelo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mysql_common-0.31.0/src/value/mod.rs:59:1
    |
59  | pub enum Value {
    | ^^^^^^^^^^^^^^
note: `mysql::Value` is defined in crate `mysql_common`
   --> /Users/marcelo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mysql_common-0.30.6/src/value/mod.rs:59:1
    |
59  | pub enum Value {
    | ^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `mysql_common` are being used?
```

Updating rust-mysql-simple to use mysql_common 0.31.0 fixes the issue


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 286aa7b..6dc9777 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,6 +36,7 @@ default = [
     "mysql_common/rust_decimal",
     "mysql_common/time",
     "mysql_common/frunk",
+    "mysql_common/binlog",
 
     "derive",
     # use global buffer pool by default
@@ -75,7 +76,7 @@ crossbeam = "0.8.1"
 io-enum = "1.0.0"
 flate2 = { version = "1.0", default-features = false }
 lru = "0.10"
-mysql_common = { version = "0.30", default-features = false }
+mysql_common = { version = "0.31", default-features = false }
 socket2 = "0.5.2"
 once_cell = "1.7.2"
 pem = "2.0.1"
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 04b97f1..fc17a10 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -45,11 +45,11 @@ jobs:
           SSL=false COMPRESS=true cargo test
           SSL=true COMPRESS=true cargo test
 
-          SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk
-          SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk
+          SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
+          SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
 
-          SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk
-          SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk
+          SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
+          SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
         env:
           RUST_BACKTRACE: 1
           DATABASE_URL: mysql://root:root@localhost:3306/mysql
@@ -91,11 +91,11 @@ jobs:
           SSL=false COMPRESS=true cargo test
           SSL=true COMPRESS=true cargo test
 
-          SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk
-          SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk
+          SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
+          SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
 
-          SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk
-          SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk
+          SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
+          SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
         env:
           RUST_BACKTRACE: 1
           DATABASE_URL: mysql://root@localhost/mysql
@@ -142,11 +142,11 @@ jobs:
           SSL=false COMPRESS=true cargo test
           SSL=true COMPRESS=true cargo test
 
-          SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk
-          SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk
+          SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
+          SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
 
-          SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk
-          SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk
+          SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
+          SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog
         env:
           RUST_BACKTRACE: 1
           DATABASE_URL: mysql://root:password@localhost/mysql
@@ -218,11 +218,11 @@ jobs:
           docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=$SSL cargo test"
           docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=$SSL COMPRESS=true cargo test"
 
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk"
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
 
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk"
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
         env:
           RUST_BACKTRACE: 1
           DATABASE_URL: mysql://root:password@localhost/mysql
@@ -290,11 +290,11 @@ jobs:
           docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true cargo test"
           docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=true cargo test"
 
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk"
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=false cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=true COMPRESS=true cargo test --no-default-features --features rustls-tls,flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
 
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk"
-          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=true cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
+          docker exec container bash -l -c "cd \$HOME && DATABASE_URL=$DATABASE_URL SSL=false COMPRESS=false cargo test --no-default-features --features flate2/zlib,mysql_common/time,mysql_common/frunk,mysql_common/binlog"
         env:
           RUST_BACKTRACE: 1
           DATABASE_URL: mysql://root:password@localhost/mysql
diff --git a/src/conn/binlog_stream.rs b/src/conn/binlog_stream.rs
index b25b801..74a26de 100644
--- a/src/conn/binlog_stream.rs
+++ b/src/conn/binlog_stream.rs
@@ -77,7 +77,7 @@ impl Iterator for BinlogStream {
         if first_byte == Some(0) {
             let event_data = &packet[1..];
             match self.esr.read(event_data) {
-                Ok(event) => Some(Ok(event)),
+                Ok(event) => Some(Ok(event?)),
                 Err(err) => Some(Err(err.into())),
             }
         } else {
diff --git a/src/conn/mod.rs b/src/conn/mod.rs
index 04ae573..ddc9ca2 100644
--- a/src/conn/mod.rs
+++ b/src/conn/mod.rs
@@ -11,7 +11,7 @@ use mysql_common::{
     constants::UTF8MB4_GENERAL_CI,
     crypto,
     io::{ParseBuf, ReadMysqlExt},
-    named_params::parse_named_params,
+    named_params::ParsedNamedParams,
     packets::{
         binlog_request::BinlogRequest, AuthPlugin, AuthSwitchRequest, Column, ComChangeUser,
         ComChangeUserMoreData, ComStmtClose, ComStmtExecuteRequestBuilder, ComStmtSendLongData,
@@ -1275,8 +1275,15 @@ impl Queryable for Conn {
 
     fn prep<T: AsRef<str>>(&mut self, query: T) -> Result<Statement> {
         let query = query.as_ref();
-        let (named_params, real_query) = parse_named_params(query.as_bytes())?;
-        self._prepare(real_query.borrow())
+        let parsed = ParsedNamedParams::parse(query.as_bytes())?;
+        let named_params: Vec<Vec<u8>> =
+            parsed.params().iter().map(|param| param.to_vec()).collect();
+        let named_params = if named_params.len() == 0 {
+            None
+        } else {
+            Some(named_params)
+        };
+        self._prepare(parsed.borrow().query())
             .map(|inner| Statement::new(inner, named_params))
     }
 


Test patch: