-
Notifications
You must be signed in to change notification settings - Fork 848
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
EXPLAIN (GENERIC_PLAN)
does not correctly handle 0 args
#2133
Comments
EXPLAIN (GENERIC_PLAN)
does not correctly handle query parametersEXPLAIN (GENERIC_PLAN)
does not correctly handle 0 args
By default, pgx uses the extended protocol in which there are separate steps for parsing, describing, and executing the statement. It appears that PostgreSQL is parsing the explain statement as if the
Output:
So PostgreSQL is reporting that the statement In theory, you should be able to pass So ultimately, to get this to work you would need to drop down to the pgconn layer.
|
Thanks for the prompt reply! This sounds pretty interesting - just to check I'm understanding you here:
And then in A fun one for sure 😆 On the upside, if it's a more general PostgreSQL bug, maybe someone else has seen it too... I'll see if I can ask about it upstream and will update this issue if I get a response - it's possible the PostgreSQL maintainers would expect clients to handle this (although I doubt it). Many thanks for providing the workaround - it's much preferred over using a different DB driver in the one place I need to use this :D |
Yes, I think you have it. |
Describe the bug
When using
EXPLAIN (GENERIC_PLAN)
on a PG16 database, pgx incorrectly tries to assign values from the args toQuery
to the query parameters. In this scenario it should probably error if any args are provided instead.To Reproduce
Given the database schema (in a postgres 16 DB)
And the following go code:
Running
Gives
Expected behavior
I expected pgx to recognise that
explain (generic_plan)
does not require arguments to be provided, accept the query, and return the query plan provided by the databasePSQL correctly returns the query plan as expected
Actual behavior
pgx returns an error, as no arguments were provided to the query.
Version
go version go1.23.1 darwin/arm64
PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(a freshly installed docker container running on an M1 Pro)github.com/jackc/pgx/v5 v5.7.1
github.com/jackc/pgx/v4 v4.18.3
Additional context
simpleQuery
if no args are providedThe text was updated successfully, but these errors were encountered: