Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions tokio-postgres/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ where
I: IntoIterator<Item = &'a dyn ToSql>,
I::IntoIter: ExactSizeIterator,
{
let buf = encode(client, &statement, params)?;
let buf = if log::log_enabled!(log::Level::Debug) {
let params = params.into_iter().collect::<Vec<_>>();
log::debug!(
"executing statement {} with parameters: {:?}",
statement.name(),
params,
);
encode(client, &statement, params)?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

} else {
encode(client, &statement, params)?
};
let responses = start(client, buf).await?;
Ok(RowStream {
statement,
Expand Down Expand Up @@ -59,7 +69,17 @@ where
I: IntoIterator<Item = &'a dyn ToSql>,
I::IntoIter: ExactSizeIterator,
{
let buf = encode(client, &statement, params)?;
let buf = if log::log_enabled!(log::Level::Debug) {
let params = params.into_iter().collect::<Vec<_>>();
log::debug!(
"executing statement {} with parameters: {:?}",
statement.name(),
params,
);
encode(client, &statement, params)?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run the params through slice_iter here? That should minimize extra instantiations of encode.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, will require a bit more work to make that happen. I'll deal with it on my end.

} else {
encode(client, &statement, params)?
};
let mut responses = start(client, buf).await?;

loop {
Expand Down