Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plan B] fix(connection): prefer_socket=false should work, fix prisma/prisma#24010 #6

Open
wants to merge 1 commit into
base: vendored-openssl
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,15 @@ impl Conn {
let read_max_allowed_packet = self.opts().max_allowed_packet().is_none();
let read_wait_timeout = self.opts().wait_timeout().is_none();

let settings: Option<Row> = if read_socket || read_max_allowed_packet || read_wait_timeout {
self.query_internal("SELECT @@socket, @@max_allowed_packet, @@wait_timeout")
let query_marks = [read_socket, read_max_allowed_packet, read_wait_timeout];
let query_variables: Vec<&str> = ["@@socket", "@@max_allowed_packet", "@@wait_timeout"].iter()
.enumerate()
.filter(|&(i, _)| query_marks[i])
.map(|(_, &x)| x)
.collect();

let settings: Option<Row> = if query_variables.len() > 0 {
self.query_internal(format!("SELECT {}", query_variables.join(", ")).to_string())
.await?
} else {
None
Expand Down