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
database/sql: cannot select query when args number is huge #41163
Comments
PostgreSQL doesn't support more than 65535 query
parameters. See
the source code. The error
message is weird, but it's probably an error
in |
@ainar-g nope, that is not postgres limit. i've try query with even 65540 in usual jetbrains db console and it works fine. If you want to make sure, just copy my code, replace 33th string with |
@ainar-g I've took a look on source, you have posted, now its really weird that it works from console, anyway, that is not correct error message and it have to be fixed. |
If you remove the dollar signs, then they are not parameters, they are literal values. That's different. There either isn't a limit on those or it's higher. The error message is confusing and should be fixed,
but again, I'm not sure if that's
|
yep, you are right about parameters, it was my stupid mistake. |
anyway, i`ve create pr to github.com/lib/pq with fix, but i think it will take a long time from their side until it will be merged, so it will be great from developers of database/sql to fix it on this library layer. |
/cc @bradfitz @kardianos @kevinburke per owners. |
What is the bug in database/sql? I didn't see it articulated above. |
@kardianos it will be great if call of sql.Tx.Prepare() from database/sql will throw some correct error(something like "number of args more then allowed") when it was created with sql.Db initialized with driver "postgres" and args number in query string($1,$2....) more then 65535, because https://github.com/lib/pq (standard postgreSQL driver) throws incorrect error(sql: expected 0 arguments, got 65536) and it goes right through database/sql layer to developers and really confused them. |
This limit is specific to postgresql. Yes, the driver should probably error out here. The sql package allows for it to return an error. I cannot check for this number, as it is by far not the only driver out there. SQL Server also has a limit, but it is different. I cannot know the limit for each database, only the drivers will. I don't think this is fixable at this layer. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
for more details https://github.com/GlebZabl/golang_postgres_bug
The text was updated successfully, but these errors were encountered: