Skip to content

Commit

Permalink
crates: Upgrade dependencies
Browse files Browse the repository at this point in the history
This commit upgrades many of our dependencies to newer versions. Note
that this was not just the result of a `cargo update` invocation; I used
the `cargo-edit` tool to automate the process of upgrading crate
versions in our Cargo.toml (I also ran `cargo update` afterwards for
good measure). The code changes in this commit reflect breaking API
changes in the new package versions.

Change-Id: I9f50620001055aca48616d602ab12a4791b57d17
  • Loading branch information
ethowitz committed May 4, 2024
1 parent 1ec7d26 commit e532cd8
Show file tree
Hide file tree
Showing 59 changed files with 248 additions and 365 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion array2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#![feature(int_roundings)]
use std::fmt::Debug;
use std::ops::{Index, IndexMut};
use std::usize;

use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/src/reporting/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ impl AnalysisInfo {

#[derive(Debug)]
pub struct Stats {
pub samples: i64,
pub mean: f64,
pub stdev: f64,
}

impl Stats {
pub fn with(hist: &hdrhistogram::Histogram<u64>) -> Stats {
Stats {
samples: hist.len() as i64,
mean: hist.mean(),
stdev: hist.stdev(),
}
Expand Down
1 change: 0 additions & 1 deletion benchmarks/src/reporting/storage/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ struct Data {
impl Data {
fn to_stats(&self) -> Stats {
Stats {
samples: self.samples as i64,
mean: self.mean,
stdev: self.stdev,
}
Expand Down
1 change: 0 additions & 1 deletion benchmarks/src/reporting/storage/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ impl Storage for PostgresStorage {
None
}
[row, ..] => Some(Stats {
samples: row.get(0),
mean: row.get(1),
stdev: row.get(2),
}),
Expand Down
2 changes: 1 addition & 1 deletion dataflow-state/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(stmt_expr_attributes, bound_map, iter_order_by, bound_as_ref)]
#![feature(stmt_expr_attributes, iter_order_by, bound_as_ref)]

mod key;
mod keyed_state;
Expand Down
3 changes: 3 additions & 0 deletions mysql-srv/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use crate::myc::constants::{CapabilityFlags, Command as CommandByte, UTF8MB4_GEN
#[derive(Debug)]
pub struct ClientHandshake<'a> {
pub capabilities: CapabilityFlags,
#[allow(dead_code)]
pub maxps: u32,
#[allow(dead_code)]
pub charset: u16,
pub username: &'a str,
pub password: &'a [u8],
Expand All @@ -24,6 +26,7 @@ pub struct ClientChangeUser<'a> {
pub username: &'a str,
pub password: &'a [u8],
pub database: Option<&'a str>,
#[allow(dead_code)]
pub charset: u16,
pub auth_plugin_name: &'a str,
}
Expand Down
52 changes: 8 additions & 44 deletions mysql-srv/src/value/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,59 +456,23 @@ mod tests {
);*/
rt!(f64_one, f64, 1.0, ColumnType::MYSQL_TYPE_DOUBLE, false);

rt!(
u8_max,
u8,
u8::max_value(),
ColumnType::MYSQL_TYPE_TINY,
false
);
rt!(
i8_max,
i8,
i8::max_value(),
ColumnType::MYSQL_TYPE_TINY,
true
);
rt!(
u16_max,
u16,
u16::max_value(),
ColumnType::MYSQL_TYPE_SHORT,
false
);
rt!(
i16_max,
i16,
i16::max_value(),
ColumnType::MYSQL_TYPE_SHORT,
true
);
rt!(
u32_max,
u32,
u32::max_value(),
ColumnType::MYSQL_TYPE_LONG,
false
);
rt!(
i32_max,
i32,
i32::max_value(),
ColumnType::MYSQL_TYPE_LONG,
true
);
rt!(u8_max, u8, u8::MAX, ColumnType::MYSQL_TYPE_TINY, false);
rt!(i8_max, i8, i8::MAX, ColumnType::MYSQL_TYPE_TINY, true);
rt!(u16_max, u16, u16::MAX, ColumnType::MYSQL_TYPE_SHORT, false);
rt!(i16_max, i16, i16::MAX, ColumnType::MYSQL_TYPE_SHORT, true);
rt!(u32_max, u32, u32::MAX, ColumnType::MYSQL_TYPE_LONG, false);
rt!(i32_max, i32, i32::MAX, ColumnType::MYSQL_TYPE_LONG, true);
rt!(
u64_max,
u64,
u64::max_value(),
u64::MAX,
ColumnType::MYSQL_TYPE_LONGLONG,
false
);
rt!(
i64_max,
i64,
i64::max_value(),
i64::MAX,
ColumnType::MYSQL_TYPE_LONGLONG,
true
);
Expand Down
90 changes: 27 additions & 63 deletions mysql-srv/src/value/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ where
// NOTE: yes, I know the = / => distinction is ugly
macro_rules! like_try_into {
($self:ident, $source:ty = $target:ty, $w:ident, $m:ident, $c:ident) => {{
let min = <$target>::min_value() as $source;
let max = <$target>::max_value() as $source;
let min = <$target>::MIN as $source;
let max = <$target>::MAX as $source;
if *$self <= max && *$self >= min {
$w.$m(*$self as $target)
} else {
Err(bad($self, $c))
}
}};
($self:ident, $source:ty => $target:ty, $w:ident, $m:ident, $c:ident) => {{
let min = <$target>::min_value() as $source;
let max = <$target>::max_value() as $source;
let min = <$target>::MIN as $source;
let max = <$target>::MAX as $source;
if *$self <= max && *$self >= min {
$w.$m::<LittleEndian>(*$self as $target)
} else {
Expand Down Expand Up @@ -684,25 +684,25 @@ impl ToMySqlValue for myc::value::Value {
// smallest containing type, and then call on that
let signed = !c.colflags.contains(ColumnFlags::UNSIGNED_FLAG);
if signed {
if n >= i64::from(i8::min_value()) && n <= i64::from(i8::max_value()) {
if n >= i64::from(i8::MIN) && n <= i64::from(i8::MAX) {
(n as i8).to_mysql_bin(w, c)
} else if n >= i64::from(i16::min_value()) && n <= i64::from(i16::max_value()) {
} else if n >= i64::from(i16::MIN) && n <= i64::from(i16::MAX) {
(n as i16).to_mysql_bin(w, c)
} else if n >= i64::from(i32::min_value()) && n <= i64::from(i32::max_value()) {
} else if n >= i64::from(i32::MIN) && n <= i64::from(i32::MAX) {
(n as i32).to_mysql_bin(w, c)
} else {
n.to_mysql_bin(w, c)
}
} else if n < 0 {
Err(bad(self, c))
} else if n <= i64::from(u8::max_value()) {
} else if n <= i64::from(u8::MAX) {
(n as u8).to_mysql_bin(w, c)
} else if n <= i64::from(u16::max_value()) {
} else if n <= i64::from(u16::MAX) {
(n as u16).to_mysql_bin(w, c)
} else if n <= i64::from(u32::max_value()) {
} else if n <= i64::from(u32::MAX) {
(n as u32).to_mysql_bin(w, c)
} else {
// must work since u64::max_value() > i64::max_value(), and n >= 0
// must work since u64::MAX > i64::MAX, and n >= 0
(n as u64).to_mysql_bin(w, c)
}
}
Expand Down Expand Up @@ -793,14 +793,14 @@ mod tests {
rt!(f32_one, f32, 1.0);
rt!(f64_one, f64, 1.0);

rt!(u8_max, u8, u8::max_value());
rt!(i8_max, i8, i8::max_value());
rt!(u16_max, u16, u16::max_value());
rt!(i16_max, i16, i16::max_value());
rt!(u32_max, u32, u32::max_value());
rt!(i32_max, i32, i32::max_value());
rt!(u64_max, u64, u64::max_value());
rt!(i64_max, i64, i64::max_value());
rt!(u8_max, u8, u8::MAX);
rt!(i8_max, i8, i8::MAX);
rt!(u16_max, u16, u16::MAX);
rt!(i16_max, i16, i16::MAX);
rt!(u32_max, u32, u32::MAX);
rt!(i32_max, i32, i32::MAX);
rt!(u64_max, u64, u64::MAX);
rt!(i64_max, i64, i64::MAX);

rt!(opt_none, Option<u8>, None);
rt!(opt_some, Option<u8>, Some(1));
Expand Down Expand Up @@ -927,59 +927,23 @@ mod tests {
);*/
rt!(f64_one, f64, 1.0, ColumnType::MYSQL_TYPE_DOUBLE, false);

rt!(
u8_max,
u8,
u8::max_value(),
ColumnType::MYSQL_TYPE_TINY,
false
);
rt!(
i8_max,
i8,
i8::max_value(),
ColumnType::MYSQL_TYPE_TINY,
true
);
rt!(
u16_max,
u16,
u16::max_value(),
ColumnType::MYSQL_TYPE_SHORT,
false
);
rt!(
i16_max,
i16,
i16::max_value(),
ColumnType::MYSQL_TYPE_SHORT,
true
);
rt!(
u32_max,
u32,
u32::max_value(),
ColumnType::MYSQL_TYPE_LONG,
false
);
rt!(
i32_max,
i32,
i32::max_value(),
ColumnType::MYSQL_TYPE_LONG,
true
);
rt!(u8_max, u8, u8::MAX, ColumnType::MYSQL_TYPE_TINY, false);
rt!(i8_max, i8, i8::MAX, ColumnType::MYSQL_TYPE_TINY, true);
rt!(u16_max, u16, u16::MAX, ColumnType::MYSQL_TYPE_SHORT, false);
rt!(i16_max, i16, i16::MAX, ColumnType::MYSQL_TYPE_SHORT, true);
rt!(u32_max, u32, u32::MAX, ColumnType::MYSQL_TYPE_LONG, false);
rt!(i32_max, i32, i32::MAX, ColumnType::MYSQL_TYPE_LONG, true);
rt!(
u64_max,
u64,
u64::max_value(),
u64::MAX,
ColumnType::MYSQL_TYPE_LONGLONG,
false
);
rt!(
i64_max,
i64,
i64::max_value(),
i64::MAX,
ColumnType::MYSQL_TYPE_LONGLONG,
true
);
Expand Down
44 changes: 14 additions & 30 deletions mysql-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@ pub struct MySqlTime {
}

impl MySqlTime {
/// The maximum value that a [`MySqlTime`] can represent: `838:59:59`.
pub const MAX: MySqlTime = MySqlTime {
nanos: MAX_MYSQL_TIME_SECONDS * (10 ^ 9),
};

/// The minimum value that a [`MySqlTime`] can represent: `-838:59:59`.
pub const MIN: MySqlTime = MySqlTime {
nanos: -MAX_MYSQL_TIME_SECONDS * (10 ^ 9),
};

/// Creates a new [`MySqlTime`] with the given [`chrono::Duration`].
/// Note that if the [`chrono::Duration`] surpasses the MySQL's TIME max value, then
/// the [`MySqlTime::max_value()`] is used (resp. [`MySqlTime::min_value()`] if the
/// the [`MySqlTime::MAX`] is used (resp. [`MySqlTime::MIN`] if the
/// [`chrono::Duration`] falls below the MySQL's TIME min value).
///
/// # Example
Expand Down Expand Up @@ -82,10 +92,10 @@ impl MySqlTime {
pub fn new(duration: Duration) -> MySqlTime {
let secs = duration.num_seconds();
if secs > MAX_MYSQL_TIME_SECONDS {
return MySqlTime::max_value();
return MySqlTime::MAX;
}
if secs < (-MAX_MYSQL_TIME_SECONDS) {
return MySqlTime::min_value();
return MySqlTime::MIN;
}
MySqlTime {
nanos: duration.num_nanoseconds().expect("Limit checked above"),
Expand Down Expand Up @@ -192,32 +202,6 @@ impl MySqlTime {
))
}

/// Returns the maximum value that a [`MySqlTime`] can represent: `838:59:59`.
///
/// # Example
///
/// ```rust
/// use mysql_time::MySqlTime;
///
/// let mysql_time_max: MySqlTime = MySqlTime::max_value(); // 838:59:59
/// ```
pub fn max_value() -> MySqlTime {
MySqlTime::new(Duration::seconds(MAX_MYSQL_TIME_SECONDS))
}

/// Returns the minimum value that a [`MySqlTime`] can represent: `-838:59:59`.
///
/// # Example
///
/// ```
/// use mysql_time::MySqlTime;
///
/// let mysql_time_min: MySqlTime = MySqlTime::min_value(); // -838:59:59
/// ```
pub fn min_value() -> MySqlTime {
MySqlTime::new(Duration::seconds(-MAX_MYSQL_TIME_SECONDS))
}

/// Returns the sign of the [`MySqlTime`] as 1 if it's positive, or -1 if it's negative.
///
/// # Example
Expand Down Expand Up @@ -747,7 +731,7 @@ mod tests {
#[proptest]
fn from_microseconds(#[strategy(arbitrary_duration())] duration: Duration) {
let mysql_time =
MySqlTime::from_microseconds(duration.num_microseconds().unwrap_or(i64::max_value()));
MySqlTime::from_microseconds(duration.num_microseconds().unwrap_or(i64::MAX));
let total_secs = duration.num_seconds();
assert_valid!(mysql_time, total_secs);
}
Expand Down
12 changes: 6 additions & 6 deletions nom-sql/src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ pub enum ItemPlaceholder {
ColonNumber(u32),
}

impl ToString for ItemPlaceholder {
fn to_string(&self) -> String {
impl fmt::Display for ItemPlaceholder {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ItemPlaceholder::QuestionMark => "?".to_string(),
ItemPlaceholder::DollarNumber(ref i) => format!("${}", i),
ItemPlaceholder::ColonNumber(ref i) => format!(":{}", i),
ItemPlaceholder::QuestionMark => write!(f, "?"),
ItemPlaceholder::DollarNumber(ref i) => write!(f, "${}", i),
ItemPlaceholder::ColonNumber(ref i) => write!(f, ":{}", i),
}
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ impl DialectDisplay for Literal {
write!(f, "X'{}'", b.iter().map(|v| format!("{:02X}", v)).join(""))
}
},
Literal::Placeholder(item) => write!(f, "{}", item.to_string()),
Literal::Placeholder(item) => write!(f, "{}", item),
Literal::BitVector(ref b) => {
write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion partial-map/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(btree_extract_if, bound_map)]
#![feature(btree_extract_if)]

use std::borrow::Borrow;
pub use std::collections::btree_map::{Iter, Keys, Range, Values, ValuesMut};
Expand Down
2 changes: 1 addition & 1 deletion psql-srv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(associated_type_bounds, let_chains)]
#![feature(let_chains)]
//! Bindings for emulating a PostgreSQL server.
//!
//! When developing new databases or caching layers, it can be immensely useful to test your system
Expand Down
Loading

0 comments on commit e532cd8

Please sign in to comment.