Skip to content

Commit

Permalink
Merge pull request #297 from blackbeam/v0.34-release
Browse files Browse the repository at this point in the history
v0.34 release
  • Loading branch information
blackbeam committed Mar 19, 2024
2 parents 116fa6d + 9d5ced3 commit 5a807d9
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 86 deletions.
54 changes: 36 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ license = "MIT/Apache-2.0"
name = "mysql_async"
readme = "README.md"
repository = "https://github.com/blackbeam/mysql_async"
version = "0.33.0"
version = "0.34.0"
exclude = ["test/*"]
edition = "2018"
edition = "2021"
categories = ["asynchronous", "database"]

[dependencies]
Expand All @@ -23,7 +23,7 @@ keyed_priority_queue = "0.4"
lazy_static = "1"
lru = "0.12.0"
mio = { version = "0.8.0", features = ["os-poll", "net"] }
mysql_common = { version = "0.31", default-features = false }
mysql_common = { version = "0.32", default-features = false }
once_cell = "1.7.2"
pem = "3.0"
percent-encoding = "2.1.0"
Expand All @@ -42,7 +42,7 @@ twox-hash = "1"
url = "2.1"

[dependencies.tokio-rustls]
version = "0.24.0"
version = "0.25"
optional = true

[dependencies.tokio-native-tls]
Expand All @@ -54,12 +54,12 @@ version = "0.2"
optional = true

[dependencies.rustls]
version = "0.21.0"
features = ["dangerous_configuration"]
version = "0.22.2"
features = []
optional = true

[dependencies.rustls-pemfile]
version = "1.0.1"
version = "2.1.0"
optional = true

[dependencies.webpki]
Expand All @@ -68,7 +68,7 @@ features = ["std"]
optional = true

[dependencies.webpki-roots]
version = "0.25.0"
version = "0.26.1"
optional = true

[dev-dependencies]
Expand All @@ -80,38 +80,56 @@ tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread"] }
[features]
default = [
"flate2/zlib",
"mysql_common/bigdecimal",
"mysql_common/rust_decimal",
"mysql_common/time",
"mysql_common/frunk",
"bigdecimal",
"rust_decimal",
"time",
"frunk",
"derive",
"native-tls-tls",
"binlog",
]

default-rustls = [
"flate2/rust_backend",
"mysql_common/bigdecimal",
"mysql_common/rust_decimal",
"mysql_common/time",
"mysql_common/frunk",
"bigdecimal",
"rust_decimal",
"time",
"frunk",
"derive",
"rustls-tls",
"binlog",
]

# minimal feature set with system flate2 impl
minimal = ["flate2/zlib"]
# minimal feature set with rust flate2 impl
minimal-rust = ["flate2/rust_backend"]

# native-tls based TLS support
native-tls-tls = ["native-tls", "tokio-native-tls"]

# rustls based TLS support
rustls-tls = [
"rustls",
"tokio-rustls",
"webpki",
"webpki-roots",
"rustls-pemfile",
]
tracing = ["dep:tracing"]

# mysql_common features
derive = ["mysql_common/derive"]
nightly = []
chrono = ["mysql_common/chrono"]
time = ["mysql_common/time"]
bigdecimal = ["mysql_common/bigdecimal"]
rust_decimal = ["mysql_common/rust_decimal"]
frunk = ["mysql_common/frunk"]
binlog = ["mysql_common/binlog"]

# other features
tracing = ["dep:tracing"]
nightly = []

[lib]
name = "mysql_async"
path = "src/lib.rs"
Expand Down
22 changes: 11 additions & 11 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ jobs:
maxParallel: 10
matrix:
v80:
DB_VERSION: "8-debian"
DB_VERSION: "8.0-debian"
v57:
DB_VERSION: "5-debian"
DB_VERSION: "5.7-debian"
v56:
DB_VERSION: "5.6"
steps:
Expand All @@ -114,9 +114,13 @@ jobs:
displayName: Run MySql in Docker
- bash: |
docker exec container bash -l -c "mysql -uroot -ppassword -e \"SET old_passwords = 1; GRANT ALL PRIVILEGES ON *.* TO 'root2'@'%' IDENTIFIED WITH mysql_old_password AS 'password'; SET PASSWORD FOR 'root2'@'%' = OLD_PASSWORD('password')\"";
docker exec container bash -l -c "echo 'deb [trusted=yes] http://archive.debian.org/debian/ stretch main non-free contrib' > /etc/apt/sources.list"
docker exec container bash -l -c "echo 'deb-src [trusted=yes] http://archive.debian.org/debian/ stretch main non-free contrib ' >> /etc/apt/sources.list"
docker exec container bash -l -c "echo 'deb [trusted=yes] http://archive.debian.org/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list"
docker exec container bash -l -c "echo 'deb [trusted=yes] http://repo.mysql.com/apt/debian/ stretch mysql-5.6' > /etc/apt/sources.list.d/mysql.list"
condition: eq(variables['DB_VERSION'], '5.6')
- bash: |
docker exec container bash -l -c "apt-get update"
docker exec container bash -l -c "apt-get --allow-unauthenticated -y update"
docker exec container bash -l -c "apt-get install -y curl clang libssl-dev pkg-config build-essential"
docker exec container bash -l -c "curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable"
displayName: Install Rust in docker
Expand All @@ -138,20 +142,16 @@ jobs:
strategy:
maxParallel: 10
matrix:
v107:
DB_VERSION: "10.7"
v113:
DB_VERSION: "11.3"
v1011:
DB_VERSION: "10.11"
v106:
DB_VERSION: "10.6"
v105:
DB_VERSION: "10.5"
v104:
DB_VERSION: "10.4"
v103:
DB_VERSION: "10.3"
v102:
DB_VERSION: "10.2"
v101:
DB_VERSION: "10.1"
steps:
- bash: |
sudo apt-get update
Expand Down
19 changes: 14 additions & 5 deletions src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// modified, or distributed except according to those terms.

use futures_util::FutureExt;
pub use mysql_common::named_params;

use mysql_common::{
constants::{DEFAULT_MAX_ALLOWED_PACKET, UTF8MB4_GENERAL_CI, UTF8_GENERAL_CI},
Expand Down Expand Up @@ -575,6 +574,10 @@ impl Conn {
Some(self.inner.auth_plugin.borrow()),
self.capabilities(),
Default::default(), // TODO: Add support
self.inner
.opts
.max_allowed_packet()
.unwrap_or(DEFAULT_MAX_ALLOWED_PACKET) as u32,
);

// Serialize here to satisfy borrow checker.
Expand Down Expand Up @@ -1544,17 +1547,23 @@ mod test {
&["mysql_native_password"]
};

for plugin in plugins {
for (i, plugin) in plugins.iter().enumerate() {
let mut rng = rand::thread_rng();
let mut pass = [0u8; 10];
pass.try_fill(&mut rng).unwrap();
let pass: String = IntoIterator::into_iter(pass)
.map(|x| ((x % (123 - 97)) + 97) as char)
.collect();

conn.query_drop("DROP USER /*!50700 IF EXISTS */ /*M!100103 IF EXISTS */ __mats")
.await
.unwrap();
let result = conn
.query_drop("DROP USER /*!50700 IF EXISTS */ /*M!100103 IF EXISTS */ __mats")
.await;
if matches!(conn.server_version(), (5, 6, _)) && i == 0 {
// IF EXISTS is not supported on 5.6 so the query will fail on the first iteration
drop(result);
} else {
result.unwrap();
}

if conn.inner.is_mariadb || conn.server_version() < (5, 7, 0) {
if matches!(conn.server_version(), (5, 6, _)) {
Expand Down
7 changes: 5 additions & 2 deletions src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

pub use url::ParseError;

mod tls;
pub mod tls;

use mysql_common::{
named_params::MixedParamsError, params::MissingNamedParameterError,
Expand Down Expand Up @@ -243,7 +243,10 @@ impl From<mysql_common::packets::ServerError<'_>> for ServerError {
ServerError {
code: packet.error_code(),
message: packet.message_str().into(),
state: packet.sql_state_str().into(),
state: packet
.sql_state_ref()
.map(|s| s.as_str().into_owned())
.unwrap_or_else(|| "HY000".to_owned()),
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/error/tls/rustls_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

use std::fmt::Display;

use rustls::server::VerifierBuilderError;

#[derive(Debug)]
pub enum TlsError {
Tls(rustls::Error),
Pki(webpki::Error),
InvalidDnsName(webpki::InvalidDnsNameError),
VerifierBuilderError(VerifierBuilderError),
}

impl From<TlsError> for crate::Error {
Expand All @@ -15,6 +18,12 @@ impl From<TlsError> for crate::Error {
}
}

impl From<VerifierBuilderError> for TlsError {
fn from(e: VerifierBuilderError) -> Self {
TlsError::VerifierBuilderError(e)
}
}

impl From<rustls::Error> for TlsError {
fn from(e: rustls::Error) -> Self {
TlsError::Tls(e)
Expand Down Expand Up @@ -57,6 +66,7 @@ impl std::error::Error for TlsError {
TlsError::Tls(e) => Some(e),
TlsError::Pki(e) => Some(e),
TlsError::InvalidDnsName(e) => Some(e),
TlsError::VerifierBuilderError(e) => Some(e),
}
}
}
Expand All @@ -67,6 +77,7 @@ impl Display for TlsError {
TlsError::Tls(e) => e.fmt(f),
TlsError::Pki(e) => e.fmt(f),
TlsError::InvalidDnsName(e) => e.fmt(f),
TlsError::VerifierBuilderError(e) => e.fmt(f),
}
}
}
Loading

0 comments on commit 5a807d9

Please sign in to comment.