From 59399b9853c581f4eabab64080577c737a397a73 Mon Sep 17 00:00:00 2001 From: Joey de Waal Date: Sat, 5 Oct 2024 20:41:04 +0200 Subject: [PATCH] Postgres: force generic plan when describing statement with args --- Cargo.lock | 1 + sqlx-postgres/src/connection/describe.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 2479456482..9420f19770 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1995,6 +1995,7 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ + "bindgen", "cc", "pkg-config", "vcpkg", diff --git a/sqlx-postgres/src/connection/describe.rs b/sqlx-postgres/src/connection/describe.rs index 18aed411b3..7a77ebd295 100644 --- a/sqlx-postgres/src/connection/describe.rs +++ b/sqlx-postgres/src/connection/describe.rs @@ -12,6 +12,7 @@ use crate::HashMap; use crate::{PgColumn, PgConnection, PgTypeInfo}; use futures_core::future::BoxFuture; use smallvec::SmallVec; +use sqlx_core::executor::Executor; use sqlx_core::query_builder::QueryBuilder; use std::sync::Arc; @@ -523,6 +524,8 @@ WHERE rngtypid = $1 let mut comma = false; if params_len > 0 { + self.execute("set plan_cache_mode = force_generic_plan;").await?; + explain += "("; // fill the arguments list with NULL, which should theoretically be valid