[MDEV-11592] REPLACE IGNORE Created: 2016-12-17  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Server
Fix Version/s: 10.4

Type: Task Priority: Minor
Reporter: Nirbhay Choubey (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-7635 update defaults and simplify mysqld c... Closed

 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/



 Comments   
Comment by Marc [ 2023-01-25 ]

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.

Comment by Marc [ 2023-01-25 ]

The corresponding KB article should mention error 1906 as well.

Generated at Thu Feb 08 07:51:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.