Changeset: 2867df9b4d2e for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=2867df9b4d2e
Modified Files:
src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
Branch: embedded
Log Message:
Small bug fixes
diffs (108 lines):
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -1514,7 +1514,7 @@ public abstract class MonetConnection ex
int size = (cachesize != 0 && !isEmbedded) ? cachesize :
MonetConnection.this.getDefFetchsize();
size = maxrows != 0 ? Math.min(maxrows, size) : size;
// don't do work if it's not needed
- if (!language.getRepresentation().equals("sql") && size !=
curReplySize &&
+ if (!isEmbedded && language.getRepresentation().equals("sql")
&& size != curReplySize &&
!Arrays.deepEquals(templ,
language.getCommandTemplates())) {
sendControlCommand(ControlCommands.REPLY_SIZE, size);
// store the reply size after a successful change
@@ -1557,7 +1557,7 @@ public abstract class MonetConnection ex
case StarterHeaders.Q_TABLE:
case StarterHeaders.Q_PREPARE: {
res =
protocol.getNextResultSetResponse(MonetConnection.this,
- ResponseList.this, this.seqnr);
+ ResponseList.this, this.seqnr,
this.maxrows);
ResultSetResponse rsreponse =
(ResultSetResponse) res;
// only add this resultset to the
hashmap if it can possibly
// have an additional datablock
diff --git a/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
@@ -9,11 +9,7 @@
package nl.cwi.monetdb.mcl.protocol;
import nl.cwi.monetdb.jdbc.MonetConnection;
-import nl.cwi.monetdb.mcl.responses.AutoCommitResponse;
-import nl.cwi.monetdb.mcl.responses.SchemaResponse;
-import nl.cwi.monetdb.mcl.responses.UpdateResponse;
-import nl.cwi.monetdb.mcl.responses.DataBlockResponse;
-import nl.cwi.monetdb.mcl.responses.ResultSetResponse;
+import nl.cwi.monetdb.mcl.responses.*;
import java.io.IOException;
import java.text.ParsePosition;
@@ -177,11 +173,12 @@ public abstract class AbstractProtocol {
* @param con The current MonetDB's JDBC connection
* @param list The Response List this result set will belong to
* @param seqnr The sequence number of this result set on the Response List
+ * @param maxrows A maxrows to set if so
* @return The ResultSet instance
* @throws ProtocolException If an error in the underlying connection
happened.
*/
public abstract ResultSetResponse getNextResultSetResponse(MonetConnection
con, MonetConnection.ResponseList list,
- int seqnr)
throws ProtocolException;
+ int seqnr, int
maxrows) throws ProtocolException;
/**
* Gets the next UpdateResponse response from the server.
diff --git
a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
@@ -10,14 +10,14 @@ package nl.cwi.monetdb.mcl.protocol.oldm
import nl.cwi.monetdb.jdbc.MonetConnection;
import nl.cwi.monetdb.mcl.connection.mapi.OldMapiSocket;
+import nl.cwi.monetdb.mcl.protocol.AbstractProtocol;
import nl.cwi.monetdb.mcl.protocol.ProtocolException;
-import nl.cwi.monetdb.mcl.protocol.AbstractProtocol;
import nl.cwi.monetdb.mcl.protocol.ServerResponses;
import nl.cwi.monetdb.mcl.protocol.StarterHeaders;
import nl.cwi.monetdb.mcl.responses.AutoCommitResponse;
-import nl.cwi.monetdb.mcl.responses.UpdateResponse;
import nl.cwi.monetdb.mcl.responses.DataBlockResponse;
import nl.cwi.monetdb.mcl.responses.ResultSetResponse;
+import nl.cwi.monetdb.mcl.responses.UpdateResponse;
import java.io.IOException;
import java.nio.CharBuffer;
@@ -121,9 +121,11 @@ public class OldMapiProtocol extends Abs
this.currentServerResponseHeader =
OldMapiServerResponseParser.ParseOldMapiServerResponse(this);
if (this.currentServerResponseHeader == ServerResponses.ERROR &&
!this.lineBuffer.toString()
.matches("^[0-9A-Z]{5}!.+")) {
+ int limit = this.lineBuffer.limit();
CharBuffer newbuffer = CharBuffer.wrap(new
char[this.lineBuffer.capacity() + 7]);
- newbuffer.put("!22000!");
- newbuffer.put(this.lineBuffer.array());
+ newbuffer.put("!22000");
+ newbuffer.put(this.lineBuffer.array(), 0, limit);
+ newbuffer.limit(limit + 6);
newbuffer.flip();
this.lineBuffer = newbuffer;
}
@@ -146,16 +148,20 @@ public class OldMapiProtocol extends Abs
* @param con The current MonetDB's JDBC connection
* @param list The Response List this result set will belong to
* @param seqnr The sequence number of this result set on the Response List
+ * @param maxrows A maxrows to set if so
* @return The ResultSet instance
* @throws ProtocolException If an error in the underlying connection
happened.
*/
@Override
- public ResultSetResponse getNextResultSetResponse(MonetConnection con,
MonetConnection.ResponseList list, int seqnr)
- throws ProtocolException {
+ public ResultSetResponse getNextResultSetResponse(MonetConnection con,
MonetConnection.ResponseList list, int seqnr,
+ int maxrows) throws
ProtocolException {
int id = OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
//The order cannot be switched!!
int tuplecount =
OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
int columncount =
OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
int rowcount =
OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
+ if (maxrows != 0 && tuplecount > maxrows) {
+ tuplecount = maxrows;
+ }
return new ResultSetResponse(con, list, id, seqnr, rowcount,
tuplecount, columncount);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list