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

Postgres driver ignores .persistent(false) #3198

Open
nk9 opened this issue Apr 12, 2024 · 3 comments
Open

Postgres driver ignores .persistent(false) #3198

nk9 opened this issue Apr 12, 2024 · 3 comments
Labels

Comments

@nk9
Copy link

nk9 commented Apr 12, 2024

Bug Description

It is not presently possible to turn off the Postgres driver's use of named prepared statements. This is a blocker for users whose database doesn't support these. For example, Supabase has introduced a new pooler for all hosted instances which doesn't presently support saving these statements, so sqlx no longer works with that service.

I discovered this sqlx limitation via Discord. In a thread there, @abonander said:

The real issue is that the Postgres driver always uses named prepared statements, even if you set .persistent(false)

It doesn't have to, that's just how it's currently written.

Minimal Reproduction

I don't know how to provide this given that my reproduction steps involve using the Supabase hosted service with credentials and whatnot. However, the issue is independent of that.

Info

  • SQLx version: 0.7.3
  • SQLx features enabled: ["runtime-tokio-rustls", "json"]
  • Database server and version: Postgres 15.1 (Supabase hosted)
  • Operating system: macOS Sonoma 14.1.2
  • rustc --version: rustc 1.77.1 (7cf61ebde 2024-03-27)
@nk9 nk9 added the bug label Apr 12, 2024
@abonander
Copy link
Collaborator

It's not that it ignores the flag, strictly speaking. It does as it says on the tin: it won't retain the prepared statement after execution.

The problem is that it always prepares the statement with an explicit name because it uses the same code path for both cases.

@nk9
Copy link
Author

nk9 commented Apr 12, 2024

Is this something that a newish Rust programmer would have a chance implementing? Is it just about using a random statement name each time when the persistent flag is set to false? If it's not too complex a solution, I'd appreciate a pointer to where to make the change.

@nk9
Copy link
Author

nk9 commented Apr 25, 2024

Is this where the code is? Any pointers on what needs to change? I'm assuming it has something to do with get_or_prepare_statement

If I can fork sqlx and make a change, just so I can get my little project working, that would be fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants