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

bulk insert: LAST_INSERT_ID() returns wrong value

    XMLWordPrintable

Details

    Description

      This might be related to MDEV-16593:

      After bulk insert the function LAST_INSERT_ID() returns wrong value.

        def test_conpy_15(self):
          cursor=self.connection.cursor()
          cursor.execute("CREATE OR REPLACE TABLE t1 (a int not null auto_increment primary key, b varchar(20))");
          self.assertEqual(cursor.lastrowid, 0)
          cursor.execute("INSERT INTO t1 VALUES (null, 'foo')")
          self.assertEqual(cursor.lastrowid, 1)
          cursor.execute("SELECT LAST_INSERT_ID()")
          row= cursor.fetchone()
          self.assertEqual(row[0], 1)
          vals= [(3, "bar"), (4, "this")]
          cursor.executemany("INSERT INTO t1 VALUES (?,?)", vals)
          self.assertEqual(cursor.lastrowid, 4)
          cursor.execute("SELECT LAST_INSERT_ID()")
          row= cursor.fetchone()
          # row[0] is 1 instead of 4 !!!
          self.assertEqual(row[0], 4)
          del cursor
      

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            georg Georg Richter
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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