Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16263

mysql_client_test: test_mysql_insert_id fails

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5.60, 10.2.14
    • 10.4
    • Tests
    • None
    • Fedora 27
      RHEL 7

    Description

      Fedora - mariadb 10.2.14

      #####################################
      200 of (1/1): test_mysql_insert_id  
      #####################################
       
       [MySQL-10.2.14-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
       
       [MySQL-10.2.14-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
       
       [MySQL-10.2.14-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
       
       [MySQL-10.2.14-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
      /builddir/build/BUILD/mariadb-10.2.14/tests/mysql_client_test.c:15638: check failed: 'res == 20'
      MySQL error 0: 
      1
      
      

      RHEL 7 - mariadb 5.5.60

      #####################################
      199 of (1/1): test_mysql_insert_id  
      #####################################
       
       [MySQL-5.5.60-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
       
       [MySQL-5.5.60-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
       
       [MySQL-5.5.60-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
       
       [MySQL-5.5.60-MariaDB][1062] Duplicate entry '12' for key 'PRIMARY'
      /builddir/build/BUILD/mariadb-5.5.60/tests/mysql_client_test.c:15333: check failed: 'res == 20'
      MySQL error 0: 
      1
      

      State of the table after the command
      insert into t2 values (null,last_insert_id(300));

      MariaDB [client_test_db]> select * from t2;
      +----+------+
      | f1 | f2   |
      +----+------+
      |  1 | a    |
      |  2 | b    |
      |  5 | c    |
      |  6 | d    |
      | 10 | a    |
      | 11 | b    |
      | 12 | a    |
      | 13 | b    |
      | 14 | a    |
      | 15 | b    |
      | 16 | a    |
      | 17 | b    |
      | 26 | 300  |
      +----+------+
      


      Clearly, the auto_increment bump on unsuccessful queries too.
      Leading to the next value being 26 instead of 20.

      If I print the res value it says 26, so the assumption in the comment about auto_increment priority is correct

        rc= mysql_query(mysql, "insert into t2 values (null,last_insert_id(300))");
        myquery(rc);
        res= mysql_insert_id(mysql);
        /*
          according to the manual, this might be 20 or 300, but it looks like
          auto_increment column takes priority over last_insert_id().
        */
        DIE_UNLESS(res == 20);
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mschorm Michal Schorm
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.