From e3b3806db5fc5054cf8dca1347b2ff705b4c0436 Mon Sep 17 00:00:00 2001 From: Julius de Bruijn Date: Mon, 6 Jul 2020 14:53:45 +0200 Subject: [PATCH] Handle `ParameterStatus` in `PgStream` --- sqlx-core/src/postgres/connection/establish.rs | 7 ------- sqlx-core/src/postgres/connection/stream.rs | 8 ++++++++ tests/postgres/postgres.rs | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sqlx-core/src/postgres/connection/establish.rs b/sqlx-core/src/postgres/connection/establish.rs index 84219b41..c6d25d02 100644 --- a/sqlx-core/src/postgres/connection/establish.rs +++ b/sqlx-core/src/postgres/connection/establish.rs @@ -98,13 +98,6 @@ impl PgConnection { } }, - MessageFormat::ParameterStatus => { - // informs the frontend about the current (initial) - // setting of backend parameters - - // we currently have no use for that data so we promptly ignore this message - } - MessageFormat::BackendKeyData => { // provides secret-key data that the frontend must save if it wants to be // able to issue cancel requests later diff --git a/sqlx-core/src/postgres/connection/stream.rs b/sqlx-core/src/postgres/connection/stream.rs index 024d9558..5e640851 100644 --- a/sqlx-core/src/postgres/connection/stream.rs +++ b/sqlx-core/src/postgres/connection/stream.rs @@ -104,6 +104,14 @@ impl PgStream { } } + MessageFormat::ParameterStatus => { + // informs the frontend about the current (initial) + // setting of backend parameters + + // we currently have no use for that data so we promptly ignore this message + continue; + } + MessageFormat::NoticeResponse => { // do we need this to be more configurable? // if you are reading this comment and think so, open an issue diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index 2f38b614..8666d8cb 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -546,3 +546,9 @@ async fn it_closes_statement_from_cache_issue_470() -> anyhow::Result<()> { Ok(()) } + +#[sqlx_macros::test] +async fn it_can_handle_parameter_status_message_issue_484() -> anyhow::Result<()> { + new::().await?.execute("SET NAMES 'UTF8'").await?; + Ok(()) +}