fix(postgres) use signed int for length prefix in PgCopyIn#3701
Conversation
|
Yeah, ultimately this doesn't really matter because Postgres is hardcoded to reject messages above a certain size depending on the message type:
This includes the 4-byte length prefix, which is why it's actually Writing a The reason why #3440 is so dangerous is that unchecked casts from I commented on #3696 (comment) for what the fix should look like. |
PgCopyIn
I figured that's why postgres would still work with small payloads but would hang with big ones. Thanks for the detailed reply, I'll try and come up with a more correct solution for this PR and #3696. |
While looking into #3696 I noticed that
CopyDatauses ani32to represent the length prefix. However, theAsyncReadimpl uses anu32. https://github.com/launchbadge/sqlx/blob/a83395a360296db1251e6e4138b6e6331912c3d4/sqlx-postgres/src/copy.rs#L233