You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, a key piece of information I had forgotten was that whether an integer is interpreted as signed or unsigned is context-dependent! And in fact, Postgres interprets this Int16 as unsigned, meaning the max number of parameters supported is actually 65535 (2^16 - 1). This is confirmed by Appendix K of the manual: https://www.postgresql.org/docs/current/limits.html
A quick, easy and correct fix would be to just change num_params to u16, but I think this should also be clarified in Postgres' docs.
The text was updated successfully, but these errors were encountered:
The sentence used to be factually correct, when it didn't mention
whether they're signed or unsigned. If we want to do better than that,
we'd need to go through all the mentions of IntN in the docs and
explicitly say which ones are signed and which ones unsigned. Perhaps
use Uint16 or Uint32 for the unsigned ones.
Over 12 years ago.
It seems to me that adjusting the description of the fields themselves either wasn't considered, or was an unsatisfactory solution.
In #3441 I added this bit of code to silence the
clippy::cast_possible_truncation
warning:sqlx/sqlx-postgres/src/connection/executor.rs
Lines 207 to 212 in 8a17bef
This will error if
arguments.len() > 32767
(2^15 - 1).We had modeled
Bind::num_params
asi16
so without any other context, this made sense: https://github.com/launchbadge/sqlx/blob/main/sqlx-postgres/src/message/bind.rs#L24And this seems to be supported by the documentation which gives the field type as
Int16
: https://www.postgresql.org/docs/current/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-BINDHowever, a key piece of information I had forgotten was that whether an integer is interpreted as signed or unsigned is context-dependent! And in fact, Postgres interprets this
Int16
as unsigned, meaning the max number of parameters supported is actually 65535 (2^16 - 1). This is confirmed by Appendix K of the manual: https://www.postgresql.org/docs/current/limits.htmlA quick, easy and correct fix would be to just change
num_params
tou16
, but I think this should also be clarified in Postgres' docs.The text was updated successfully, but these errors were encountered: