Bug #96059 Error streaming multi resultsets with mysql-connector-java 8.0.x
Submitted: 2 Jul 2019 8:50 Modified: 7 Jan 2020 18:07
Reporter: E A Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:8.0.16 OS:Any
Assigned to: CPU Architecture:Any
Tags: multi resultsets, Streaming

[2 Jul 2019 8:50] E A
Description:
As we know, people generally use streaming result for large resultsets.
And if there are multi resultsets which are all quite large, we just stream them all. 

However, following code runs totally fine on mysql-connector-java 5.x but just not good on 8.0.x

How to repeat:
See code below:
```
try {
    Connection conn = DriverManager.getConnection(url, user, pass);

    PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    
    ResultSet rs = null;

    stmt.setFetchSize(Integer.MIN_VALUE);

    stmt.setFetchDirection(ResultSet.FETCH_REVERSE);

    boolean hasResult = stmt.execute();

    while(hasResult) {
        rs = stmt.getResultSet();
        System.out.println("===result set===");
        while (rs.next()) {
            System.out.print("---record---");
            System.out.println(rs.getInt(1));
        }
        hasResult = stmt.getMoreResults();
    }

} catch (Exception e) {
    e.printStackTrace();
}
```
It's good to go on mysql-connector-java 5.x, but throw exceptions on 8.0.x

Suggested fix:
some bugs in `ClientPreparedStatement.getMoreResults()` of 8.0.x
[2 Jul 2019 10:10] MySQL Verification Team
Hello CHAO AI,

Thank you for the report.

regards,
Umesh
[5 Nov 2019 12:42] Dmitriy Tseyler
Any news?
[5 Nov 2019 12:43] Dmitriy Tseyler
Any news?
[5 Nov 2019 12:43] Dmitriy Tseyler
Any news?
[20 Nov 2019 21:49] Ken Grigsby
Any news?
[12 Dec 2019 14:02] James Braswell
Hello, 

I am currently experiencing this error while trying to stream results from a stored procedure while using DataGrip 2019.3. Thank you.
[7 Jan 2020 18:07] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 8.0.19 changelog:

"Streaming of multiple result sets failed with an error. It was due to an error in switching the streamer source from one result set to another, and this fix corrects the issue"