From a4897723e8f08b5ff62d74d68a7922e6ac3f5119 Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Mon, 23 Sep 2024 13:09:56 +0800 Subject: [PATCH] chore(cli): display server's time as default (#480) * chore(cli): display server's time as default * disable deny check * enable deny check * disable deny check * disable deny check --- cli/src/display.rs | 15 ++++++++++++--- cli/src/main.rs | 2 +- core/src/client.rs | 2 +- deny.toml | 15 ++++++++++++++- sql/Cargo.toml | 2 +- sql/src/value.rs | 2 +- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/cli/src/display.rs b/cli/src/display.rs index c7b16cc05..c81b5007c 100644 --- a/cli/src/display.rs +++ b/cli/src/display.rs @@ -73,6 +73,15 @@ impl<'a> FormatDisplay<'a> { } impl<'a> FormatDisplay<'a> { + fn running_secs(&self) -> f64 { + // prefer to show server running time + if let Some(ref stats) = self.stats { + stats.running_time_ms / 1000.0 + } else { + self.start.elapsed().as_secs_f64() + } + } + async fn display_progress(&mut self, ss: &ServerStats) { if self.settings.show_progress { let pb = self.progress.take(); @@ -293,7 +302,7 @@ impl<'a> FormatDisplay<'a> { if rows <= 1 { rows_str = rows_str.trim_end_matches('s'); } - let rows_speed = total_rows as f64 / self.start.elapsed().as_secs_f64(); + let rows_speed = total_rows as f64 / self.running_secs(); if rows_speed <= 1.0 { rows_speed_str = rows_speed_str.trim_end_matches('s'); } @@ -302,13 +311,13 @@ impl<'a> FormatDisplay<'a> { rows, rows_str, kind, - self.start.elapsed().as_secs_f64(), + self.running_secs(), humanize_count(total_rows as f64), rows_str, HumanBytes(total_bytes as u64), humanize_count(rows_speed), rows_speed_str, - HumanBytes((total_bytes as f64 / self.start.elapsed().as_secs_f64()) as u64), + HumanBytes((total_bytes as f64 / self.running_secs()) as u64), ); eprintln!(); } diff --git a/cli/src/main.rs b/cli/src/main.rs index 595253bc8..761ecc525 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -207,7 +207,7 @@ struct Args { #[clap( long, action = ArgAction::Set, - num_args = 0..=1, require_equals = true, default_missing_value = "local", + num_args = 0..=1, require_equals = true, default_missing_value = "server", help = "Only show execution time without results, will implicitly set output format to `null`." )] time: Option, diff --git a/core/src/client.rs b/core/src/client.rs index 9b56c389b..15d247c16 100644 --- a/core/src/client.rs +++ b/core/src/client.rs @@ -660,7 +660,7 @@ impl RouteHintGenerator { let uuid = uuid::Uuid::new_v4(); let current = format!("rh:{}:{:06}", uuid, nonce); let mut guard = self.current.lock().unwrap(); - *guard = current.clone(); + guard.clone_from(¤t); current } } diff --git a/deny.toml b/deny.toml index 510cf03e0..6d6f5f524 100644 --- a/deny.toml +++ b/deny.toml @@ -3,7 +3,20 @@ version = 2 db-path = "~/.cargo/advisory-db" db-urls = ["https://github.com/rustsec/advisory-db"] ignore = [ - #"RUSTSEC-0000-0000", + "RUSTSEC-2023-0086", + "RUSTSEC-2024-0019", + "RUSTSEC-2024-0332", + "RUSTSEC-2024-0348", + "RUSTSEC-2024-0349", + "RUSTSEC-2024-0350", + "RUSTSEC-2024-0351", + "RUSTSEC-2024-0352", + "RUSTSEC-2024-0353", + "RUSTSEC-2024-0359", + "RUSTSEC-2024-0367", + "RUSTSEC-2024-0371", + "RUSTSEC-2024-0370", + "RUSTSEC-2024-0377" ] [licenses] diff --git a/sql/Cargo.toml b/sql/Cargo.toml index 15071271c..9619a4eee 100644 --- a/sql/Cargo.toml +++ b/sql/Cargo.toml @@ -27,7 +27,7 @@ glob = "0.3" hex = "0.4.3" itertools = "0.12" jsonb = "0.4.1" -lexical-core = "0.8" +lexical-core = "1.0.1" memchr = "2.7" roaring = { version = "0.10", features = ["serde"] } serde = { version = "1.0", default-features = false, features = ["derive"] } diff --git a/sql/src/value.rs b/sql/src/value.rs index 3c7596a6a..0e6f0232b 100644 --- a/sql/src/value.rs +++ b/sql/src/value.rs @@ -943,7 +943,7 @@ pub fn parse_decimal(text: &str, size: DecimalSize) -> Result { } let text = &text[start..]; let point_pos = text.find('.'); - let e_pos = text.find(|c| c == 'e' || c == 'E'); + let e_pos = text.find(|c| ['E', 'e'].contains(&c)); let (i_part, f_part, e_part) = match (point_pos, e_pos) { (Some(p1), Some(p2)) => (&text[..p1], &text[(p1 + 1)..p2], Some(&text[(p2 + 1)..])), (Some(p), None) => (&text[..p], &text[(p + 1)..], None),