Open
Description
It seems the encoding for MSSQL does not understand strings beyond 255 characters in length, and causes the server to abort reads after sending more data than the server expects. I was attempting to make a PR to add Vec<u8> -> BigVarBinary
support, but it was unclear to me how to encode variable-length types from either of the SQLX pattern perspective or the actual TSQL wire protocol.
At the very least, it seems to me that - rather than crashing - the encode should fail if it is aware that it cannot represent the type. This may also be true for other dialects, if they are susceptible to the same pattern of too-long-of-input resulting in a wire-protocol-level failure?
To reproduce:
- Add the following test (replacing the existing
str<String>
one) totests/mssql/types.rs
(Yes, it's a bit verbose, but the test_type macro prevented me from using dynamically-constructed strings in its current form):
test_type!(str<String>(Mssql,
"'01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456'"
==
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456",
"''" == "",
));
- Run the unit tests for
mssql
- Note that the above strings are 257 characters long; at ~560, the behaviour changes slightly with regards to timing, but the error remains the same. I'm not clear how this variable-length encoding is supposed to work, as I couldn't find documentation on what signals use of a u16 or u32 in place of the single-byte length specifier.