mariadb/mysql-test/suite/innodb/r/innodb-replace.result
Thirunarayanan Balathandayuthapani 7afee25b08 MDEV-35115 Inconsistent Replace behaviour when multiple unique index exist
- Replace statement fails with duplicate key error when multiple
unique key conflict happens. Reason is that Server expects the
InnoDB engine to store the confliciting keys in ascending order.
But the InnoDB doesn't store the conflicting keys
in ascending order.

Fix:
===
- Enable HA_DUPLICATE_KEY_NOT_IN_ORDER for InnoDB storage engine
only when unique index order is different in .frm and innodb dictionary.
2024-11-08 16:46:41 +05:30

63 lines
2.1 KiB
Text
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

drop table if exists t1;
create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb;
select * from t1;
c1 c2 stamp
replace delayed into t1 (c1, c2) values ( "text1","11");
ERROR HY000: DELAYED option not supported for table 't1'
select * from t1;
c1 c2 stamp
replace delayed into t1 (c1, c2) values ( "text1","12");
ERROR HY000: DELAYED option not supported for table 't1'
select * from t1;
c1 c2 stamp
drop table t1;
#
# MDEV-35115 Inconsistent Replace behaviour when multiple
# unique index exist
#
CREATE TABLE t1 (c1 NUMERIC UNSIGNED NOT NULL,
c2 INT3 UNIQUE,
c3 BIT(2) PRIMARY KEY)ENGINE=InnoDB;
ALTER TABLE t1 ADD UNIQUE INDEX(c1);
INSERT INTO t1 (c1,c2,c3) VALUES (0,0,b'01');
INSERT INTO t1 (c1,c2,c3) VALUES (1,1,b'10');
FLUSH STATUS;
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN ('HANDLER_DELETE','HANDLER_WRITE','HANDLER_READ_KEY','HANDLER_UPDATE');
VARIABLE_NAME VARIABLE_VALUE
HANDLER_DELETE 0
HANDLER_READ_KEY 0
HANDLER_UPDATE 0
HANDLER_WRITE 0
REPLACE INTO t1 (c1,c2,c3) VALUES (0,1,b'11');
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN ('HANDLER_DELETE','HANDLER_WRITE','HANDLER_READ_KEY','HANDLER_UPDATE');
VARIABLE_NAME VARIABLE_VALUE
HANDLER_DELETE 1
HANDLER_READ_KEY 2
HANDLER_UPDATE 1
HANDLER_WRITE 2
SELECT * FROM t1;
c1 c2 c3
0 1 
DROP TABLE t1;
CREATE TABLE t1 (f1 INT NOT NULL PRIMARY KEY,
f2 INT, f3 INT, f4 INT,
UNIQUE INDEX i1(f2))ENGINE=InnoDB;
ALTER TABLE t1 ADD INDEX i3(f4);
ALTER TABLE t1 ADD UNIQUE INDEX i2(f3);
INSERT INTO t1 VALUES (0,0,0,0);
INSERT INTO t1 VALUES (1,1,1,1);
FLUSH STATUS;
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN ('HANDLER_DELETE','HANDLER_WRITE','HANDLER_READ_KEY','HANDLER_UPDATE');
VARIABLE_NAME VARIABLE_VALUE
HANDLER_DELETE 0
HANDLER_READ_KEY 0
HANDLER_UPDATE 0
HANDLER_WRITE 0
REPLACE INTO t1 VALUES (0,0,1,1);
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN ('HANDLER_DELETE','HANDLER_WRITE','HANDLER_READ_KEY','HANDLER_UPDATE');
VARIABLE_NAME VARIABLE_VALUE
HANDLER_DELETE 1
HANDLER_READ_KEY 2
HANDLER_UPDATE 1
HANDLER_WRITE 2
DROP TABLE t1;