-
Notifications
You must be signed in to change notification settings - Fork 488
Handle DEALLOCATE ALL and DISCARD ALL for prepared statements #972
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think supporting DEALLOCATE ALL is a worthy effort. It currently silently breaks the whole server. And because there is no protocol level equivalent, all clients that want send this need to send it as SQL.
When I saw the title of this PR I thought I was going to hate it, because I'd expect it to implement a very simple query parser. And I was happily surprised that's not what's going on. Instead it's using the command tag from the CommandComplete packet. And I actually think that idea is quite elegant, since the command tags are well defined by postgres and easy to parse (as opposed to SQL which can have comments or extra spaces or lowercase). So I quite like this general approach. I left some comments on changes that should be done to make this handle some more edge cases.
Also this needs some tests. And docs need to be updated that we now actually do support DEALLOCATE ALL
I have just opened #974, which explains the problem and thus motivation behind such a change a bit more. Great to see there is already a PR aiming to fix this problem! 💚 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. All it now needs is a test.
Also CI is complaining about the codeformatting. |
6ff253f
to
0fe4542
Compare
0fe4542
to
7252998
Compare
While this is not "query parsing", it still assumes semantics about the contained SQL commands that are not part of the protocol specification. How might this affect non-PostgreSQL uses of PgBouncer. |
To be clear, you're talking about other databases that use the Postgres protocol, but don't speak Postgres its SQL dialect, right? If so, then (tl;dr) I think the impact would be negligable. The "CommandComplete parsing" here would only have any impact in practice if the server responded with
While in theory it's possible that some other non-PostgreSQL server implements a |
…cer#972) This implements a hacky/clever approach of handling the `DEALLOCATE ALL` and `DISCARD ALL` SQL statements. Instead of parsing the queries themselves, which PgBouncer avoids doing completely, this parses the CommandComplete packet returned by the server. Fixes prisma/prisma#21635 Fixes pgbouncer#974
## Problem Update pgbouncer from 1.21 (and patches[0][1]) to 1.22 (which includes these patches) - [0] pgbouncer/pgbouncer#972 - [1] pgbouncer/pgbouncer#998 ## Summary of changes - Build pgbouncer 1.22.0 for neonVMs from upstream
This implements a hacky/clever approach of handling the
DEALLOCATE ALL
andDISCARD ALL
SQL statements. Instead of parsing the queries themselves, which PgBouncer avoids doing completely, this parses the CommandComplete packet returned by the server.Fixes prisma/prisma#21635
Fixes #974