Skip to content

Commit

Permalink
inline the first explain using smallvec
Browse files Browse the repository at this point in the history
  • Loading branch information
jwangnz committed Sep 6, 2023
1 parent 1a36f8e commit 8566197
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sqlx-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ log = "0.4.17"
memchr = { version = "2.4.1", default-features = false }
num-bigint = { version = "0.4.3", optional = true }
once_cell = "1.9.0"
smallvec = "1.7.0"
smallvec = { version = "1.7.0", features = ["serde"] }
stringprep = "0.1.2"
thiserror = "1.0.35"
tracing = { version = "0.1.37", features = ["log"] }
Expand Down
6 changes: 4 additions & 2 deletions sqlx-postgres/src/connection/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::types::Oid;
use crate::HashMap;
use crate::{PgArguments, PgColumn, PgConnection, PgTypeInfo};
use futures_core::future::BoxFuture;
use smallvec::SmallVec;
use std::fmt::Write;
use std::sync::Arc;

Expand Down Expand Up @@ -447,7 +448,8 @@ WHERE rngtypid = $1
explain += ")";
}

let (Json(explains),): (Json<Vec<Explain>>,) = query_as(&explain).fetch_one(self).await?;
let (Json(explains),): (Json<SmallVec<[Explain; 1]>>,) =
query_as(&explain).fetch_one(self).await?;

let mut nullables = Vec::new();

Expand All @@ -460,7 +462,7 @@ WHERE rngtypid = $1
}) = explains.first()
{
nullables.resize(outputs.len(), None);
visit_plan(plan, outputs, &mut nullables);
visit_plan(&plan, outputs, &mut nullables);
}

Ok(nullables)
Expand Down

0 comments on commit 8566197

Please sign in to comment.