FirebirdSQL / NETProvider

Firebird ADO.NET Data Provider
https://firebirdsql.org/en/net-provider/
Other
161 stars 66 forks source link

Support higher maximum blob segment size #1197

Open mrotteveel opened 1 month ago

mrotteveel commented 1 month ago

Currently, the blob segment size is controlled by the connection property PacketSize, and this has a maximum value of 32767 (bytes). However, since Firebird 2.1, segment sizes of 64KiB - 1 are supported (though Firebird 2.1 and 2.5 have some issues because sometimes the value is cast to a SSHORT, as far as I know, Firebird 3.0 is the first where it really works).

There are some oddities with this maximum, because for op_get_segment the maximum is also the maximum size of the buffer used for transferring, so the largest value you can receive with op_get_segment when asking for 65535 is actually 65533 (and if the response is broken up in multiple segments, it can even be multiples of 2 shorter) because of the 2-byte length prefixes in the response buffer. When sending (op_put_segment), the maximum is 65535 bytes.

Support a larger maximum value, so blobs can be transferred more efficiently, at least for Firebird 3.0 and higher, and also consider deprecating PacketSize, and/or introduce an alternative property called BlobSegmentSize, as that seems to be the only thing controlled by PacketSize.