PreparedQuery limited to 65535 elements
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
a reproducer would be great :-)
I created one here: https://github.com/pribault/preparedQuery-reproducer I'm running a PostgreSQL server v10, you'll have to update some variables in the MainVerticle like your PostgreSQL server url, username etc... And create the table as described in the readme
thank you
On Thu, Feb 17, 2022 at 12:05 PM pribault @.***> wrote:
I created one here: https://github.com/pribault/preparedQuery-reproducer I'm running a PostgreSQL server v10, you'll have to update some variables in the MainVerticle like your PostgreSQL server url, username etc... And create the table as described in the readme
— Reply to this email directly, view it on GitHub https://github.com/eclipse-vertx/vertx-sql-client/issues/1142#issuecomment-1042832856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXDCRCV7VORTYQBH7OBDDU3TI77ANCNFSM5OSEOTLA . You are receiving this because you commented.Message ID: @.***>
Fixed by cc9803f0