Skip to content

PreparedQuery limited to 65535 elements #1142

Description

@pribault

Version

Vertx: 4.2.4

Context

When using prepared queries with a really high number of elements a NoStackTraceThrowable exception can be raised with the following message:
The number of parameters to execute should be consistent with the expected number of parameters = [64464] but the actual number is [130000].
In my case I tried to send 130000 parameters, but only 64464 were taken.
After a little bit of investigation I found that inside the PgEncoder (inside the writeParse method), we're making a call to ByteBuf.writeShort to write the number of parameter types. This leads to a limit of 65535 elements for a prepared query (the max number that shorts can take), and explains my exception (64464 is the truncated version of 130000 as an unsigned short).
I think we should either throw a more verbose exception when the prepared query is exceeding the limit of 65535 elements (and write it in the documentation), or either use a bigger type like int or long to store the number of elements.

Do you have a reproducer?

I don't have a reproducer for now, I can try to give you one if necessary but I think the problem is pretty clear

Thank you in advance

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions