1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
create table t1(a blob unique) engine= InnoDB;
insert into t1 values('RUC');
insert into t1 values ('RUC');
ERROR 23000: Duplicate entry 'RUC' for key 'a'
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
t1 0 a 1 a A 1 NULL NULL YES HASH NO
drop table t1;
create table t1 (a blob unique , c int unique) engine=innodb;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` blob DEFAULT NULL,
`c` int(11) DEFAULT NULL,
UNIQUE KEY `c` (`c`),
UNIQUE KEY `a` (`a`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
drop table t1;
#test for concurrent insert of long unique in innodb
create table t1(a blob unique) engine= InnoDB;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` blob DEFAULT NULL,
UNIQUE KEY `a` (`a`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
connect 'con1', localhost, root,,;
connect 'con2', localhost, root,,;
connection con1;
set innodb_lock_wait_timeout= 2;
set transaction isolation level READ UNCOMMITTED;
start transaction;
insert into t1 values('RUC');
connection con2;
set innodb_lock_wait_timeout= 2;
set transaction isolation level READ UNCOMMITTED;
start transaction;
insert into t1 values ('RUC');
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection con1;
commit;
set transaction isolation level READ COMMITTED;
start transaction;
insert into t1 values('RC');
connection con2;
commit;
set transaction isolation level READ COMMITTED;
start transaction;
insert into t1 values ('RC');
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
connection con1;
commit;
set transaction isolation level REPEATABLE READ;
start transaction;
insert into t1 values('RR');
connection con2;
commit;
set transaction isolation level REPEATABLE READ;
start transaction;
insert into t1 values ('RR');
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection con1;
commit;
set transaction isolation level SERIALIZABLE;
start transaction;
insert into t1 values('S');
connection con2;
commit;
set transaction isolation level SERIALIZABLE;
start transaction;
insert into t1 values ('S');
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
connection con1;
commit;
select * from t1;
a
RUC
RC
RR
S
drop table t1;
create table t1(a blob unique) engine=Innodb;
connection con1;
set transaction isolation level READ UNCOMMITTED;
start transaction;
insert into t1 values('RUC');
connection con2;
set transaction isolation level READ UNCOMMITTED;
start transaction;
insert into t1 values ('RUC');;
connection con1;
rollback;
connection con2;
commit;
connection con1;
set transaction isolation level READ COMMITTED;
start transaction;
insert into t1 values('RC');
connection con2;
set transaction isolation level READ COMMITTED;
start transaction;
insert into t1 values ('RC');;
connection con1;
rollback;
connection con2;
commit;
connection con1;
set transaction isolation level REPEATABLE READ;
start transaction;
insert into t1 values('RR');
connection con2;
set transaction isolation level REPEATABLE READ;
start transaction;
insert into t1 values ('RR');;
connection con1;
rollback;
connection con2;
commit;
connection con1;
set transaction isolation level SERIALIZABLE;
start transaction;
insert into t1 values('S');
connection con2;
set transaction isolation level SERIALIZABLE;
start transaction;
insert into t1 values ('S');;
connection con1;
rollback;
connection con2;
commit;
connection default;
drop table t1;
disconnect con1;
disconnect con2;
# MDEV-20131 Assertion `!pk->has_virtual()' failed
create table t1 (a text, primary key(a(1871))) engine=innodb;
ERROR 42000: Specified key was too long; max key length is 1536 bytes
# End of 10.4 tests
#
# MDEV-37268 ER_NOT_KEYFILE or assertion failure upon REPLACE into table with unique hash under READ-COMMITTED
#
create table t1 (id int not null primary key, f varchar(100), unique(f) using hash) engine=innodb;
insert t1 values (1,'x');
set transaction isolation level read committed;
replace t1 values (2,'x');
select * from t1;
id f
2 x
drop table t1;
create table t1 (id int, f longtext, primary key (id), unique(f)) engine=innodb partition by key (id) partitions 9;
insert t1 (id) values (1),(2);
set transaction isolation level read committed;
update ignore t1 set f = 'x';
ERROR 42000: UPDATE IGNORE in READ COMMITTED isolation mode of a table with a UNIQUE constraint USING HASH is not currently supported
select * from t1;
id f
1 NULL
2 NULL
drop table t1;
#
# MDEV-37310 Non-debug failing assertion node->pcur->rel_pos == BTR_PCUR_ON upon violating long unique under READ-COMMITTED
#
create table t1 (id int, f blob, unique(id,f)) engine=innodb partition by key(id) partitions 2;
insert t1 values (1,'foo'),(2,'foo');
set transaction isolation level read committed;
update ignore t1 set id = 2;
ERROR 42000: UPDATE IGNORE in READ COMMITTED isolation mode of a table with a UNIQUE constraint USING HASH is not currently supported
select * from t1;
id f
1 foo
2 foo
drop table t1;
# End of 10.6 tests
|