Skip to content

Commit

Permalink
Merge pull request #522 from project-tsurugi/amend
Browse files Browse the repository at this point in the history
eliminate the Blob/Clob data field when the setting value of the fiel…
  • Loading branch information
t-horikawa authored Feb 6, 2025
2 parents d1710cf + abb7414 commit d140a44
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tsurugidb.sql.proto.SqlCommon;
import com.tsurugidb.sql.proto.SqlRequest;
import com.tsurugidb.sql.proto.SqlResponse;
import com.tsurugidb.tsubakuro.common.BlobInfo;
Expand Down Expand Up @@ -120,8 +121,7 @@ public FutureResponse<ExecuteResult> executeStatement(
.setPreparedStatementHandle(((PreparedStatementImpl) statement).getHandle());
var lobs = new LinkedList<BlobInfo>();
for (SqlRequest.Parameter e : parameters) {
pb.addParameters(e);
addLob(e, lobs);
pb.addParameters(addLob(e, lobs));
}
if (lobs.isEmpty()) {
return service.send(pb.build());
Expand All @@ -144,8 +144,7 @@ public FutureResponse<ResultSet> executeQuery(
.setPreparedStatementHandle(((PreparedStatementImpl) statement).getHandle());
var lobs = new LinkedList<BlobInfo>();
for (SqlRequest.Parameter e : parameters) {
pb.addParameters(e);
addLob(e, lobs);
pb.addParameters(addLob(e, lobs));
}
if (lobs.isEmpty()) {
return service.send(pb.build());
Expand All @@ -154,7 +153,7 @@ public FutureResponse<ResultSet> executeQuery(
}
}

private void addLob(SqlRequest.Parameter e, LinkedList<BlobInfo> lobs) {
private SqlRequest.Parameter addLob(SqlRequest.Parameter e, LinkedList<BlobInfo> lobs) {
if (e.getValueCase() == SqlRequest.Parameter.ValueCase.CLOB) {
var v = e.getClob();
switch (v.getDataCase()) {
Expand All @@ -166,6 +165,11 @@ private void addLob(SqlRequest.Parameter e, LinkedList<BlobInfo> lobs) {
default:
throw new UnsupportedOperationException();
}
return SqlRequest.Parameter.newBuilder()
.setClob(SqlCommon.Clob.newBuilder()
.setChannelName(v.getChannelName())
.build())
.build();
}
if (e.getValueCase() == SqlRequest.Parameter.ValueCase.BLOB) {
var v = e.getBlob();
Expand All @@ -178,7 +182,13 @@ private void addLob(SqlRequest.Parameter e, LinkedList<BlobInfo> lobs) {
default:
throw new UnsupportedOperationException();
}
return SqlRequest.Parameter.newBuilder()
.setBlob(SqlCommon.Blob.newBuilder()
.setChannelName(v.getChannelName())
.build())
.build();
}
return e;
}

@Override
Expand Down

0 comments on commit d140a44

Please sign in to comment.