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

INSERT ON DUPLICATE KEY UPDATE produces error 1032 (Can't find record)

    XMLWordPrintable

Details

    Description

      The linked bug (MDEV-15042) appears to not be fixed, or has regressed in the affected versions. The provided test script (also below) still produces the 'Cant' find record in <tablename>' as opposed to the more helpful FK error.

      Test Script:

      CREATE DATABASE `testdb`;
      USE `testdb`;
       
      CREATE TABLE `parent` (
          `id` INT PRIMARY KEY AUTO_INCREMENT
      ) ENGINE=INNODB;
       
      CREATE TABLE `child` (
          -- crucial bit: FK has to be primary key (or if composite, at the start of the primary key)
          `parent_id` INT NOT NULL PRIMARY KEY,
          `id` INT NOT NULL,
          CONSTRAINT `fk_c_parent` FOREIGN KEY (`parent_id`) REFERENCES `parent`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
      ) ENGINE=INNODB;
       
      -- This works as expected, producing a 1452 error (foreign key constraint fails)
       
      INSERT INTO `child` (`id`, `parent_id`) VALUES (1, 1);
       
      -- ERROR 1032 (HY000): Can't find record in 'child'
       
      INSERT INTO `child` (`id`, `parent_id`) VALUES (1, 1) ON DUPLICATE KEY UPDATE `id` = VALUES(`id`);
      

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              rmhumphries Robert Humphries
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.