Skip to content

Commit

Permalink
fix(mysql): improve compatibility with ProxySQL
Browse files Browse the repository at this point in the history
Joins the MySQL connection setup statements into a single statement to
prevent issues with ProxySQL, which requires special handling of
connections that might be shared between multiple backends.

Fixes launchbadge#422

Signed-off-by: Marcus Griep <marcus@griep.us>
  • Loading branch information
neoeinstein committed Jun 21, 2020
1 parent 37e59f1 commit 274826e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sqlx-core/src/mysql/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ impl Connect for MySqlConnection {

// https://mathiasbynens.be/notes/mysql-utf8mb4

conn.execute(r#"
SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE'));
SET time_zone = '+00:00';
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
"#).await?;
conn.execute(concat!(
r#"SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE')),"#,
r#"time_zone='+00:00',"#,
r#"NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;"#,
)).await?;

Ok(conn)
})
Expand Down

0 comments on commit 274826e

Please sign in to comment.