Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-434

ResultSet returns duplicate entries

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.8
    • Fix Version/s: 1.5.9
    • Component/s: Other
    • 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;
      

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            pskiwi Andreas Pillath
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration