Details

    Description

      While INSERT, UPDATE, DELETE and LOAD DATA INFILE all support
      IGNORE construct, REPLACE does not have this option.

      MariaDB [test]> select @@sql_mode;
      +---------------------+
      | @@sql_mode          |
      +---------------------+
      | STRICT_TRANS_TABLES |
      +---------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> create table t1(i int primary key, j varchar(10)) engine=innodb;
      Query OK, 0 rows affected (0.03 sec)
       
      MariaDB [test]> insert into t1 values('aaa', 'bbb');
      ERROR 1366 (22007): Incorrect integer value: 'aaa' for column 'i' at row 1
       
      MariaDB [test]> insert into t1 values('aaa', 'bbb');
      ERROR 1366 (22007): Incorrect integer value: 'aaa' for column 'i' at row 1
       
      MariaDB [test]> insert ignore into t1 values('aaa', 'bbb');
      Query OK, 1 row affected, 1 warning (0.01 sec)
       
      MariaDB [test]> show warnings;
      +---------+------+--------------------------------------------------------+
      | Level   | Code | Message                                                |
      +---------+------+--------------------------------------------------------+
      | Warning | 1366 | Incorrect integer value: 'aaa' for column 'i' at row 1 |
      +---------+------+--------------------------------------------------------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> select * from t1;
      +---+------+
      | i | j    |
      +---+------+
      | 0 | bbb  |
      +---+------+
      1 row in set (0.00 sec)
       
      MariaDB [test]> replace into t1 values('aaa', 'bbb');
      ERROR 1366 (22007): Incorrect integer value: 'aaa' for column 'i' at row 1
       
      MariaDB [test]> replace ignore into t1 values('aaa', 'bbb');
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ignore into t1 values('aaa', 'bbb')' at line 1
      

      KB : https://mariadb.com/kb/en/mariadb/ignore/

      Attachments

        Issue Links

          Activity

            mokraemer Marc added a comment -

            Due to generated columns this would be very useful.
            Insert and replace statements generate errors (1906) if you want to write data to generated columns. So

            INSERT INTO xx (SELECT * FROM yy)
            

            fails. Adding ignore makes this useable again. But for the replace syntax there is no equivalent to ignore these errors and copy (update) data from one table to another.

            mokraemer Marc added a comment - Due to generated columns this would be very useful. Insert and replace statements generate errors (1906) if you want to write data to generated columns. So INSERT INTO xx (SELECT * FROM yy) fails. Adding ignore makes this useable again. But for the replace syntax there is no equivalent to ignore these errors and copy (update) data from one table to another.
            mokraemer Marc added a comment -

            The corresponding KB article should mention error 1906 as well.

            mokraemer Marc added a comment - The corresponding KB article should mention error 1906 as well.

            People

              Unassigned Unassigned
              nirbhay_c Nirbhay Choubey (Inactive)
              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.