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

Not following of the definition of the TIMESTAMP in the table.

    XMLWordPrintable

Details

    Description

      When we use ON DUPLICATE UPDATE syntax to insert data, CURRENT_TIMESTAMP in primary key, we get wrong answer.

      How to repeat:
      we can repeat this by mysql-test.

      create one file named 'test_update.test' in directory mysql-test/main

      The content of 'test_update.test' is:

      CREATE TABLE `test_up`(
          `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
          `data` int,
          PRIMARY KEY(`ts`) 
      );
       
      INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 1);
       
      INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 2) ON DUPLICATE KEY UPDATE data=2;
      INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 3) ON DUPLICATE KEY UPDATE data=3;
      INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 4) ON DUPLICATE KEY UPDATE data=4;
      

      now, we can use this command in directory mysql-test:

      ./mtr main.test_update
      

      now, the wrong answer is:

      mysqltest: At line 11: Query 'INSERT INTO test_up VALUES("2023-05-29 17:34:55.01", 4) ON DUPLICATE KEY UPDATE data=4' failed.
      ERROR 1062 (23000): Duplicate entry '2023-05-29 12:42:03' for key 'test_up.PRIMARY'
      

      Attachments

        Activity

          People

            serg Sergei Golubchik
            Linkang, Zhang Linkang, Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.