Skip to content

Commit

Permalink
Postgres: only set force_generic_plan for versions that support it
Browse files Browse the repository at this point in the history
  • Loading branch information
joeydewaal committed Oct 5, 2024
1 parent 5bba30d commit 819f189
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sqlx-postgres/src/connection/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,19 @@ WHERE rngtypid = $1
let mut tx = self.begin().await?;

if params_len > 0 {
tx.execute("set local plan_cache_mode = force_generic_plan;")
.await?;
tx.execute(
" DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM pg_settings
WHERE name = 'plan_cache_mode'
) THEN
SET LOCAL plan_cache_mode = 'force_generic_plan';
END IF;
END $$;",
)
.await?;

explain += "(";

Expand Down

0 comments on commit 819f189

Please sign in to comment.