mariadb/mysql-test/suite/innodb/r/change_column_collation.result
Thirunarayanan Balathandayuthapani bf0a54df34 MDEV-31416 ASAN errors in dict_v_col_t::detach upon adding key to virtual column
- InnoDB throws ASAN error while adding the index on virtual column
of system versioned table. InnoDB wrongly assumes that virtual
column collation type changes, creates new column with different
character set. This leads to failure while detaching the column
from indexes.
2023-06-08 16:34:45 +05:30

145 lines
5.1 KiB
Text

#
# MDEV-26294 Duplicate entries in unique index not detected when
# changing collation with INPLACE algorithm
#
SET NAMES utf8;
CREATE TABLE t1 (
id INT PRIMARY KEY,
msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_swedish_ci UNIQUE
) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'aaa');
INSERT INTO t1 VALUES (2, 'ååå');
ALTER TABLE t1 MODIFY msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci, ALGORITHM=inplace;
ERROR 23000: Duplicate entry 'NULL' for key 'msg'
DROP TABLE t1;
CREATE TABLE t1 (
id INT PRIMARY KEY,
msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin,
id_2 INT not null,
unique index(msg, id_2)
) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'aaa', 2);
INSERT INTO t1 VALUES (2, 'AAA', 3);
ALTER TABLE t1 MODIFY msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci, ALGORITHM=inplace;
DROP TABLE t1;
CREATE TABLE t1 (
id INT PRIMARY KEY,
msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin,
unique index(msg)
) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'aaa');
INSERT INTO t1 VALUES (2, 'bbb');
INSERT INTO t1 VALUES (3, 'ccc');
SET DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL before_apply WAIT_FOR go_ahead';
ALTER TABLE t1 MODIFY msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci, ALGORITHM=NOCOPY;
connect con1,localhost,root,,;
connection con1;
SET DEBUG_SYNC = 'now WAIT_FOR before_apply';
INSERT INTO t1 VALUES (4, 'AAA');
UPDATE t1 set msg = "ddd" where id = 2;
DELETE FROM t1 WHERE id= 3;
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
connection default;
ERROR 23000: Duplicate entry 'NULL' for key 'msg'
SET DEBUG_SYNC = 'RESET';
SELECT * FROM t1;
id msg
4 AAA
1 aaa
2 ddd
DROP TABLE t1;
CREATE TABLE t1 (
id INT PRIMARY KEY,
f1 INT NOT NULL,
f2 INT NOT NULL,
f3 INT NOT NULL,
msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin,
msg_1 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin,
unique index(f1, msg, f2, msg_1, f3),
unique index(f1, msg_1, f2, msg, f3),
unique index(f1, msg, f3, msg_1, f2),
unique index(f1, msg_1, f3, msg, f2),
unique index(f2, msg_1, f1, msg, f3),
unique index(f2, msg, f3, msg_1, f1),
unique index(f3, f2, msg, msg_1, f1),
unique index(f3, msg, msg_1, f1, f2)
) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 1, 1, 1, 'aaa', 'aaa');
SET DEBUG_DBUG="+d,create_index_fail";
SET DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL con1_go WAIT_FOR alter_signal";
ALTER TABLE t1 MODIFY msg VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci, MODIFY msg_1 VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci, ALGORITHM=NOCOPY;
connection con1;
SET DEBUG_SYNC="now WAIT_FOR con1_go";
BEGIN;
SELECT * FROM t1;
id f1 f2 f3 msg msg_1
1 1 1 1 aaa aaa
SET DEBUG_SYNC="now SIGNAL alter_signal";
connection default;
ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
connection con1;
rollback;
INSERT INTO t1 VALUES(2, 2, 2, 2, 'bbb', 'bbb');
disconnect con1;
connection default;
SET DEBUG_SYNC=reset;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`f1` int(11) NOT NULL,
`f2` int(11) NOT NULL,
`f3` int(11) NOT NULL,
`msg` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL,
`msg_1` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `f1` (`f1`,`msg`,`f2`,`msg_1`,`f3`),
UNIQUE KEY `f1_2` (`f1`,`msg_1`,`f2`,`msg`,`f3`),
UNIQUE KEY `f1_3` (`f1`,`msg`,`f3`,`msg_1`,`f2`),
UNIQUE KEY `f1_4` (`f1`,`msg_1`,`f3`,`msg`,`f2`),
UNIQUE KEY `f2` (`f2`,`msg_1`,`f1`,`msg`,`f3`),
UNIQUE KEY `f2_2` (`f2`,`msg`,`f3`,`msg_1`,`f1`),
UNIQUE KEY `f3` (`f3`,`f2`,`msg`,`msg_1`,`f1`),
UNIQUE KEY `f3_2` (`f3`,`msg`,`msg_1`,`f1`,`f2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
INSERT INTO t1 VALUES(3, 3, 3, 3, 'ccc', 'ccc');
DROP TABLE t1;
CREATE TABLE t1(id INT PRIMARY KEY, msg VARCHAR(100),
msg_1 VARCHAR(100) AS (msg) VIRTUAL,
msg_2 VARCHAR(100) AS (msg) STORED,
UNIQUE(msg), UNIQUE(msg_1),
UNIQUE(msg_2))ENGINE=InnoDB;
ALTER TABLE t1 MODIFY msg_1 VARCHAR(100) CHARACTER SET utf8
COLLATE utf8_unicode_ci, ALGORITHM=inplace;
ERROR HY000: This is not yet supported for generated columns
ALTER TABLE t1 MODIFY msg_2 VARCHAR(100) CHARACTER SET utf8
COLLATE utf8_unicode_ci, ALGORITHM=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type. Try ALGORITHM=COPY
DROP TABLE t1;
#
# MDEV-29314 Assertion `n_fields > n_cols' failed
# in dict_index_t::init_change_cols
#
CREATE TABLE t (a VARCHAR(16) COLLATE utf8_bin,
FULLTEXT (a)) ENGINE=InnoDB COLLATE utf8_unicode_520_ci;
ALTER TABLE t MODIFY COLUMN a VARCHAR(512);
SHOW CREATE TABLE t;
Table Create Table
t CREATE TABLE `t` (
`a` varchar(512) DEFAULT NULL,
FULLTEXT KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_520_ci
DROP TABLE t;
#
# MDEV-31416 ASAN errors in dict_v_col_t::detach upon
# adding key to virtual column
#
CREATE TABLE t (a INT) ENGINE=InnoDB WITH SYSTEM VERSIONING;
SET SYSTEM_VERSIONING_ALTER_HISTORY= KEEP;
ALTER TABLE t ADD COLUMN v VARCHAR(128) GENERATED ALWAYS AS (CRC32('MariaDB'));
ALTER TABLE t ADD INDEX (v);
DROP TABLE t;