Changeset: 3e78e45e9e9a for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/3e78e45e9e9a
Modified Files:
        src/main/java/org/monetdb/jdbc/MonetConnection.java
Branch: mvn
Log Message:

Fix result set leak when Statement#setMaxRows has been called.


diffs (47 lines):

diff --git a/src/main/java/org/monetdb/jdbc/MonetConnection.java 
b/src/main/java/org/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -2322,7 +2322,8 @@ public class MonetConnection
                 * be given.
                 *
                 * @param id the ID of the result set
-                * @param tuplecount the total number of tuples in the result 
set
+                * @param realtuplecount the total number of tuples in the 
result set
+                * @param tuplecount the number of tuples in the result set 
after maxRows has been applied
                 * @param columncount the number of columns in the result set
                 * @param rowcount the number of rows in the current block
                 * @param parent the parent that created this Response and will
@@ -2331,6 +2332,7 @@ public class MonetConnection
                 */
                ResultSetResponse(
                                final int id,
+                               final long realtuplecount,
                                final long tuplecount,
                                final int columncount,
                                final int rowcount,
@@ -2362,7 +2364,7 @@ public class MonetConnection
                                cacheSize = rowcount;
                        seqnr = seq;
                        closed = false;
-                       destroyOnClose = id > 0 && tuplecount > rowcount;
+                       destroyOnClose = id > 0 && realtuplecount > rowcount;
 
                        this.id = id;
                        this.tuplecount = tuplecount;
@@ -3180,13 +3182,12 @@ public class MonetConnection
                                                                case 
StartOfHeaderParser.Q_TABLE:
                                                                case 
StartOfHeaderParser.Q_PREPARE: {
                                                                        final 
int id = sohp.getNextAsInt();
-                                                                       long 
tuplecount = sohp.getNextAsLong();
+                                                                       final 
long realtuplecount = sohp.getNextAsLong();
                                                                        final 
int columncount = sohp.getNextAsInt();
                                                                        final 
int rowcount = sohp.getNextAsInt();
                                                                        // 
enforce the maxrows setting
-                                                                       if 
(maxrows != 0 && tuplecount > maxrows)
-                                                                               
tuplecount = maxrows;
-                                                                       res = 
new ResultSetResponse(id, tuplecount, columncount, rowcount, this, seqnr);
+                                                                       final 
long tuplecount = (maxrows == 0 || realtuplecount <= maxrows) ? realtuplecount 
: maxrows;
+                                                                       res = 
new ResultSetResponse(id, realtuplecount, tuplecount, columncount, rowcount, 
this, seqnr);
                                                                        // only 
add this resultset to the hashmap if it can possibly have an additional 
datablock
                                                                        if 
(rowcount < tuplecount) {
                                                                                
if (rsresponses == null)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to