summaryrefslogtreecommitdiff
path: root/mysql-test/main/long_unique_innodb.test
blob: aac68cd227182c05ca6407aec52ee450725ac270 (plain)
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
--source include/have_innodb.inc

#
# MDEV-371 Unique indexes for blobs
#

create table t1(a blob unique) engine= InnoDB;
insert into t1 values('RUC');
--error ER_DUP_ENTRY
insert into t1 values ('RUC');
drop table t1;

create table t1 (a blob unique , c int unique) engine=innodb;
show create table t1;
drop table t1;

--echo #test for concurrent insert of long unique in innodb
create table t1(a blob unique) engine= InnoDB;
show create table t1;
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;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values ('RUC');

--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;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values ('RC');
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;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values ('RR');

--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;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values ('S');
commit;

--connection con1
commit;

select * from t1;
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;
--send insert into t1 values ('RUC');
--connection con1
rollback;
--connection con2
--reap
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;
--send insert into t1 values ('RC');
--connection con1
rollback;
--connection con2
--reap
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;
--send insert into t1 values ('RR');
--connection con1
rollback;
--connection con2
--reap
commit;

--connection con1
set  transaction isolation level SERIALIZABLE;
start transaction;
insert into t1 values('S');
--connection con2
set  transaction isolation level SERIALIZABLE;
start transaction;
--send insert into t1 values ('S');
--connection con1
rollback;
--connection con2
--reap
commit;

connection default;
drop table t1;
disconnect con1;
disconnect con2;