mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-12-23 08:21:09 +00:00
refactor(jdbc): adjust empty stream handling and memory usage in setBinaryStream and setUnicodeStream
This commit is contained in:
parent
52f8c1a33e
commit
efe189c21d
1 changed files with 4 additions and 3 deletions
|
|
@ -217,7 +217,7 @@ public final class JDBC4PreparedStatement extends JDBC4Statement implements Prep
|
|||
offset += readBytes;
|
||||
}
|
||||
if (offset == 0) {
|
||||
this.statement.bindNull(parameterIndex);
|
||||
this.statement.bindText(parameterIndex, "");
|
||||
} else {
|
||||
String text = new String(buffer, 0, offset, StandardCharsets.UTF_8);
|
||||
this.statement.bindText(parameterIndex, text);
|
||||
|
|
@ -249,9 +249,10 @@ public final class JDBC4PreparedStatement extends JDBC4Statement implements Prep
|
|||
}
|
||||
if (offset == 0) {
|
||||
this.statement.bindNull(parameterIndex);
|
||||
} else if (offset == buffer.length) {
|
||||
this.statement.bindBlob(parameterIndex, buffer);
|
||||
} else {
|
||||
byte[] actualData = Arrays.copyOf(buffer, offset);
|
||||
this.statement.bindBlob(parameterIndex, actualData);
|
||||
this.statement.bindBlob(parameterIndex, Arrays.copyOf(buffer, offset));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new SQLException("Error reading binary stream", e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue