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

UPDATE IGNORE ... RETURNING ... INTO fails with ER_TOO_MANY_ROWS when the second row is skipped by IGNORE (duplicate key)

    XMLWordPrintable

Details

    • Unexpected results

    Description

      Only one row is actually updated, so the statement should succeed and assign @b=1, as plain RETURNING returns that row.

      CREATE TABLE t1 (a INT UNIQUE, b INT) ENGINE=InnoDB;
      INSERT INTO t1 VALUES (1,1),(2,2);
      UPDATE IGNORE t1 SET a=5 RETURNING b;
      SELECT * FROM t1;
      TRUNCATE TABLE t1;
      INSERT INTO t1 VALUES (1,1),(2,2);
      UPDATE IGNORE t1 SET a=5 RETURNING b INTO @b;
      DROP TABLE t1;
      

      CREATE TABLE t1 (a INT UNIQUE, b INT) ENGINE=InnoDB;
      INSERT INTO t1 VALUES (1,1),(2,2);
      UPDATE IGNORE t1 SET a=5 RETURNING b;
      b
      1
      SELECT * FROM t1;
      a	b
      5	1
      2	2
      query 'UPDATE IGNORE t1 SET a=5 RETURNING b INTO @b' failed: ER_TOO_MANY_ROWS (1172): Result consisted of more than one row
      

      branch bb-13.1-bar-MDEV-39563 230f541c44c2477c5f8296ec9e0d2ccc2b46a372.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.