[CONJ-434] ResultSet returns duplicate entries Created: 2017-02-16  Updated: 2017-02-21  Resolved: 2017-02-21

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.5.8
Fix Version/s: 1.5.9

Type: Bug Priority: Major
Reporter: Andreas Pillath Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

MariaDB 10.1.21/Windows/JDBC 1.5.8/JDK 1.8.121



 Description   

After updating to 1.5.8 from 1.5.8 I get too many results from a ResultSet.

This code should return 20 rows, but it returns 50.

Connection connection = DriverManager.getConnection(
                                                          "jdbc:mariadb://localhost:3310/test?createDatabaseIfNotExist=true",
                                                          "root", "");
      connection.createStatement().executeQuery("drop table if exists testtable ");
      connection.createStatement().executeQuery("create table testtable(s1 varchar(20))");
      for (int r = 0; r < 20; r++)
      {
         connection.createStatement().executeUpdate("insert into testtable values('V" + r + "')");
      }
      Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                                  ResultSet.CONCUR_READ_ONLY);
      stmt.setFetchSize(10);
 
      ResultSet rs = stmt.executeQuery("select * from testtable");
      int count = 0;
      while (rs.next())
      {
         System.out.println(rs.getString(1));
         count++;
      }
      System.out.println("COUNT:" + count);

This seems to be related to CONJ-418 and commit:
(https://github.com/MariaDB/mariadb-connector-j/commit/2f99de9d5346418747768bd788e11969bc0fee27#diff-eb416079e8728af2ebd351e80090441aR371)

MariaSelectResultSet.java:371 only conditionally clears the resultSet

  if (resultSetScrollType == TYPE_FORWARD_ONLY) resultSet.clear();

but always resets the rowPointer in MariaSelectResultSet.java:574

   rowPointer = 0;



 Comments   
Comment by Diego Dupin [ 2017-02-21 ]

right, this will be corrected in a 1.5.9 version with commit https://github.com/mariadb/mariadb-connector-j/commit/0138932541e1465fa9544d52f8b0d5f9b9c5d790

Generated at Thu Feb 08 03:15:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.