Skip to content

Commit b62827c

Browse files
authored
Fixed issue with Prepare and V3 protocol and quiet query output
1 parent f5b1660 commit b62827c

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

driver/src/main/java/oracle/nosql/driver/ops/QueryRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public class QueryRequest extends DurableRequest implements AutoCloseable {
136136

137137
private String queryName;
138138

139-
private boolean logFileTracing = true;
139+
private boolean logFileTracing;
140140

141141
private String driverQueryTrace;
142142

driver/src/main/java/oracle/nosql/driver/ops/serde/PrepareRequestSerializer.java

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.HashMap;
1414
import java.util.Map;
1515

16+
import oracle.nosql.driver.UnsupportedQueryVersionException;
1617
import oracle.nosql.driver.ops.PreparedStatement;
1718
import oracle.nosql.driver.ops.PrepareRequest;
1819
import oracle.nosql.driver.ops.PrepareResult;
@@ -29,27 +30,60 @@
2930
*/
3031
public class PrepareRequestSerializer extends BinaryProtocol
3132
implements Serializer {
33+
@Override
34+
public void serialize(Request request,
35+
short serialVersion,
36+
ByteOutputStream out)
37+
throws IOException {
38+
throw new IllegalArgumentException("Missing query version " +
39+
"in prepare request serializer");
40+
}
3241

3342
@Override
3443
public void serialize(Request request,
3544
short serialVersion,
45+
short queryVersion,
3646
ByteOutputStream out)
3747
throws IOException {
3848

49+
/* QUERY_V4 and above not supported by V3 protocol */
50+
if (queryVersion >= QueryDriver.QUERY_V4) {
51+
throw new UnsupportedQueryVersionException(
52+
"Query version " + queryVersion +
53+
" not supported by V3 protocol");
54+
}
55+
3956
PrepareRequest prepRq = (PrepareRequest) request;
4057

4158
writeOpCode(out, OpCode.PREPARE);
4259
serializeRequest(prepRq, out);
4360
writeString(out, prepRq.getStatement());
44-
out.writeShort(QueryDriver.QUERY_VERSION);
61+
out.writeShort(queryVersion);
4562
out.writeBoolean(prepRq.getQueryPlan());
4663
}
4764

4865
@Override
49-
public PrepareResult deserialize(Request request,
50-
ByteInputStream in,
51-
short serialVersion)
52-
throws IOException {
66+
public PrepareResult deserialize(
67+
Request request,
68+
ByteInputStream in,
69+
short serialVersion) throws IOException {
70+
throw new IllegalArgumentException("Missing query version " +
71+
"in prepare request deserializer");
72+
}
73+
74+
@Override
75+
public PrepareResult deserialize(
76+
Request request,
77+
ByteInputStream in,
78+
short serialVersion,
79+
short queryVersion) throws IOException {
80+
81+
/* QUERY_V4 and above not supported by V3 protocol */
82+
if (queryVersion >= QueryDriver.QUERY_V4) {
83+
throw new UnsupportedQueryVersionException(
84+
"Query version " + queryVersion +
85+
" not supported by V3 protocol");
86+
}
5387

5488
PrepareRequest prepRq = (PrepareRequest) request;
5589
PrepareResult result = new PrepareResult();

driver/src/main/java/oracle/nosql/driver/query/PlanIter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static PlanIterKind valueOf(int kvcode) {
136136
return kind;
137137
}
138138
}
139-
System.out.println("Unexpected iterator kind: " + kvcode);
139+
//System.out.println("Unexpected iterator kind: " + kvcode);
140140
return null;
141141
}
142142
}

0 commit comments

Comments
 (0)