diff --git a/sqlx-mysql/Cargo.toml b/sqlx-mysql/Cargo.toml index 81b603d9..433c4a1e 100644 --- a/sqlx-mysql/Cargo.toml +++ b/sqlx-mysql/Cargo.toml @@ -42,7 +42,7 @@ base64 = "0.13.0" rand = "0.7" [dev-dependencies] -sqlx-core = { version = "0.6.0-pre", path = "../sqlx-core", features = ["_mock", "tokio"] } +sqlx-core = { version = "0.6.0-pre", path = "../sqlx-core", features = ["_mock"] } futures-executor = "0.3.8" anyhow = "1.0.37" tokio = { version = "1.0", features = ["full"] } @@ -51,4 +51,4 @@ once_cell = "1.5.2" [[test]] name = "mysql-connection" path = "tests/connection.rs" -required-features = ["async"] +required-features = ["async", "sqlx-core/tokio"] diff --git a/sqlx-mysql/src/connection.rs b/sqlx-mysql/src/connection.rs index 840d7767..4a63c3f0 100644 --- a/sqlx-mysql/src/connection.rs +++ b/sqlx-mysql/src/connection.rs @@ -25,6 +25,7 @@ mod ping; pub struct MySqlConnection { stream: MySqlStream, connection_id: u32, + closed: bool, // the capability flags are used by the client and server to indicate which @@ -60,6 +61,11 @@ impl MySqlConnection { | Capabilities::DEPRECATE_EOF, } } + + /// Returns the server-assigned connection identifier associated with this connection. + pub fn id(&self) -> u32 { + self.connection_id + } } impl Debug for MySqlConnection { diff --git a/sqlx-mysql/src/connection/command.rs b/sqlx-mysql/src/connection/command.rs index df12891e..4f185047 100644 --- a/sqlx-mysql/src/connection/command.rs +++ b/sqlx-mysql/src/connection/command.rs @@ -102,7 +102,11 @@ impl Deref for CommandGuard<'_, QueryCommand> { fn deref(&self) -> &Self::Target { debug_assert!(!self.ended); - if let Command::Query(cmd) = &self.queue.0[self.index] { cmd } else { unreachable!() } + if let Command::Query(cmd) = &self.queue.0[self.index] { + cmd + } else { + unreachable!() + } } } @@ -110,7 +114,11 @@ impl DerefMut for CommandGuard<'_, QueryCommand> { fn deref_mut(&mut self) -> &mut Self::Target { debug_assert!(!self.ended); - if let Command::Query(cmd) = &mut self.queue.0[self.index] { cmd } else { unreachable!() } + if let Command::Query(cmd) = &mut self.queue.0[self.index] { + cmd + } else { + unreachable!() + } } } @@ -139,7 +147,11 @@ impl Deref for CommandGuard<'_, PrepareCommand> { fn deref(&self) -> &Self::Target { debug_assert!(!self.ended); - if let Command::Prepare(cmd) = &self.queue.0[self.index] { cmd } else { unreachable!() } + if let Command::Prepare(cmd) = &self.queue.0[self.index] { + cmd + } else { + unreachable!() + } } } @@ -147,6 +159,10 @@ impl DerefMut for CommandGuard<'_, PrepareCommand> { fn deref_mut(&mut self) -> &mut Self::Target { debug_assert!(!self.ended); - if let Command::Prepare(cmd) = &mut self.queue.0[self.index] { cmd } else { unreachable!() } + if let Command::Prepare(cmd) = &mut self.queue.0[self.index] { + cmd + } else { + unreachable!() + } } } diff --git a/sqlx-mysql/src/protocol/auth_response.rs b/sqlx-mysql/src/protocol/auth_response.rs index e109de2f..b4a10c21 100644 --- a/sqlx-mysql/src/protocol/auth_response.rs +++ b/sqlx-mysql/src/protocol/auth_response.rs @@ -5,7 +5,7 @@ use sqlx_core::io::Deserialize; use sqlx_core::Result; use crate::protocol::{AuthSwitch, Capabilities, ResultPacket}; -use crate::{MySqlClientError, MySqlDatabaseError}; +use crate::MySqlClientError; #[derive(Debug)] pub(crate) enum AuthResponse { diff --git a/sqlx-mysql/src/protocol/auth_switch.rs b/sqlx-mysql/src/protocol/auth_switch.rs index dee71c2f..1a042c9c 100644 --- a/sqlx-mysql/src/protocol/auth_switch.rs +++ b/sqlx-mysql/src/protocol/auth_switch.rs @@ -28,7 +28,7 @@ impl Deserialize<'_> for AuthSwitch { let plugin_data = buf.chain(Bytes::new()); - let plugin = AuthPlugin::parse(&*name)?; + let plugin = ::parse(&*name)?; Ok(Self { plugin, plugin_data }) } diff --git a/sqlx-mysql/src/protocol/handshake.rs b/sqlx-mysql/src/protocol/handshake.rs index 240176ec..25124c80 100644 --- a/sqlx-mysql/src/protocol/handshake.rs +++ b/sqlx-mysql/src/protocol/handshake.rs @@ -112,7 +112,7 @@ impl Deserialize<'_> for Handshake { status, auth_plugin_data: auth_plugin_data_1.chain(auth_plugin_data_2), auth_plugin: auth_plugin_name - .map(|name| AuthPlugin::parse(&name)) + .map(|name| ::parse(&name)) .transpose()? .unwrap_or_else(|| Box::new(NativeAuthPlugin)), }) diff --git a/sqlx-mysql/src/protocol/query_response.rs b/sqlx-mysql/src/protocol/query_response.rs index caa90cb0..c44d234e 100644 --- a/sqlx-mysql/src/protocol/query_response.rs +++ b/sqlx-mysql/src/protocol/query_response.rs @@ -4,7 +4,7 @@ use sqlx_core::Result; use super::{Capabilities, ResultPacket}; use crate::io::MySqlBufExt; -use crate::{MySqlClientError, MySqlDatabaseError}; +use crate::MySqlClientError; /// The query-response packet is a meta-packet that starts with one of: /// diff --git a/sqlx-mysql/src/stream.rs b/sqlx-mysql/src/stream.rs index e7829e86..04df2176 100644 --- a/sqlx-mysql/src/stream.rs +++ b/sqlx-mysql/src/stream.rs @@ -7,7 +7,7 @@ use sqlx_core::net::Stream as NetStream; use sqlx_core::{Result, Runtime}; use crate::protocol::{MaybeCommand, Packet, Quit}; -use crate::{MySqlClientError, MySqlDatabaseError}; +use crate::MySqlClientError; /// Reads and writes packets to and from the MySQL database server. /// diff --git a/x.py b/x.py index f0187400..01e26091 100755 --- a/x.py +++ b/x.py @@ -235,7 +235,7 @@ def run_integration_test(project: str, database: str): "-q" if argv.quiet else None, "--message-format", "human" if argv.verbose else "short", "--manifest-path", f"{project}/Cargo.toml", - "--features", "async", + "--features", "async,sqlx-core/tokio", *unknown, ] if x], env=env, cwd=project_dir, comment=f"integration test {project}", tag=tag)