mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-15 06:04:19 +01:00
## Purpose * Implement JDBC4 stream binding methods in JDBC4PreparedStatement for the following overloads: * `setAsciiStream(int, InputStream, long)`, `setAsciiStream(int, InputStream)` * `setBinaryStream(int, InputStream, long)`, `setBinaryStream(int, InputStream)` ## Changes ### In `(int, InputStream, long)` methods * Added a shared helper method `requireLengthIsPositiveInt(long length)` to validate stream length. * Validates `length` to fit SQLite’s 32-bit limit for compatibility with SQLite/Turso engines. * After validation passes, delegates to the `(int, InputStream, int)` overload for actual binding logic. ### In `(int, InputeStream)` methods - no length * Added a shared helper method `readBytes(InputStream x)`. * Reads the first byte before allocating the buffer to avoid unnecessary memory allocation for empty streams. * After reading, directly binds the data using` bindText()` (for ASCII) or `bindBlob()` (for binary). * Avoids re-wrapping the stream or reallocation since the byte array is already available. ## Related Issue * #615 Reviewed-by: Kim Seon Woo (@seonWKim) Closes #3937