zhztheplayer commented on a change in pull request #1132: [CALCITE-2955] SQL 
queries after first query in same statement have no results returned
URL: https://github.com/apache/calcite/pull/1132#discussion_r288418298
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java
 ##########
 @@ -608,6 +608,10 @@ public MetaResultSet getTableTypes(ConnectionHandle ch) {
             new ArrayList<List<Object>>());
     boolean done = fetchMaxRowCount == 0 || rows.size() < fetchMaxRowCount;
     @SuppressWarnings("unchecked") List<Object> rows1 = (List<Object>) rows;
+    if (done) {
 
 Review comment:
   It seems that `stmt.setResultSet(null)` should be called by the operation of 
closing the ResultSet object on client side, because inside the method 
`CalciteMetaImpl#fetch` we can barely know exactly when we should execute a new 
query (please correct me if I am wrong). 
   
   For example, you can check following test case:
    ```java
     @Test public void testFoo() throws Exception {
       try (Connection remoteConnection = getRemoteConnection()) {
         final Statement statement = remoteConnection.createStatement();
         StringBuffer stringBuffer = new StringBuffer();
         stringBuffer.append("values ");
         final int resultSize = 1000;
         for (int i = 0; i < resultSize; i++) {
           stringBuffer.append("(").append(i).append(", ").append(i + 
1).append(")");
           if (i != resultSize - 1) {
             stringBuffer.append(", ");
           }
         }
         final String sql = stringBuffer.toString();
         ResultSet resultSet = statement.executeQuery(sql);
   
         resultSet = statement.executeQuery("values (1, 'a')");
         int n = 0;
         while (resultSet.next()) {
           ++n;
         }
         assertThat(n, equalTo(1));
       }
     }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to