xtern commented on code in PR #2906:
URL: https://github.com/apache/ignite-3/pull/2906#discussion_r1435049161


##########
modules/jdbc/src/main/java/org/apache/ignite/internal/jdbc/JdbcStatement.java:
##########
@@ -711,10 +708,37 @@ void ensureNotClosed() throws SQLException {
      *
      * @throws SQLException On error.
      */
-    protected void closeResults() throws SQLException {
+    void closeResults() throws SQLException {
+        @Nullable JdbcResultSet last = null;
+
         if (resSets != null) {
-            for (JdbcResultSet rs : resSets) {
-                rs.close0();
+            JdbcResultSet lastRs = resSets.get(resSets.size() - 1);
+            boolean allFetched = lastRs == null;
+
+            if (allFetched) {
+                for (JdbcResultSet rs : resSets) {
+                    if (rs != null) {
+                        rs.close0(true);
+                    }
+                }
+            } else {
+                try {
+                    last = lastRs.getNextResultSet();
+                } catch (SQLException ex) {
+                    // TODO: https://issues.apache.org/jira/browse/IGNITE-21133
+                    // implicitly silent close previous result set.
+                }
+
+                if (last != null) {
+                    while (last != null) {
+                        try {
+                            last = last.getNextResultSet();
+                        } catch (SQLException ex) {
+                            // TODO: 
https://issues.apache.org/jira/browse/IGNITE-21133
+                            // implicitly silent close previous result set.
+                        }
+                    }
+                }

Review Comment:
   As was discussed today - let's throw error in such situation (better late 
than never).
   
   ```suggestion
               try {
                   if (allFetched) {
                       for (JdbcResultSet rs : resSets) {
                           if (rs != null) {
                               rs.close0(true);
                           }
                       }
   
                       return;
                   }
   
                   do {
                       lastRs = lastRs.getNextResultSet();
                   } while (lastRs != null);
               } finally {
                   resSets = null;
                   curRes = 0;
               }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to