~clint-fewbar/ubuntu/natty/mysql-5.1/merge-5.1.49-2

« back to all changes in this revision

Viewing changes to mysql-test/suite/innodb_plugin/t/innodb_lock_wait_timeout_1.test

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-08-04 13:18:27 UTC
  • mfrom: (1.2.2 upstream) (2.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100804131827-4tjg88vr9dd49s3k
Tags: 5.1.49-1ubuntu1
* Merge from debian unstable:
  + debian/control:
     * Update maintainer according to spec.
     * Move section from "misc" to "database".
     * Added libmysqlclient16-dev an empty transitional package. 
     * Added mysql-client-core-5.1 package.
     * Suggest mailx for mysql-server-5.1
     * Add mysql-testsuite package so you can run the testsuite seperately.
  + debian/additions/my.cnf:
    * Remove language options. Error message files are located in a different directory in Mysql
      5.0. Setting the language option to use /usr/share/mysql/english breaks Mysql 5.0. Both 5.0
      and 5.1 use a different value that works. (LP: #316974)
  + Add apparmor profile:
    + debian/apparmor-profile: apparmor-profile
    + debian/rules, debian/mysql-server-5.1.files: install apparmor profile
    + debian/mysql-server-5.1.dirs: add etc/apparmor.d/fore-complain
    + debian/mysql-server-5.1.postrm: remove symlink in force-complain/ on purge.
    + debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    + debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    + debian/mysql-server-5.1.postinst: reload apparmor profiles
  * Convert the package from sysvinit to upstart:
    + debian/mysql-server-5.1.mysql.upstart: Add upstart script.
    + debian/mysql-server-5.1.mysql.init: Dropped, unused now with upstart.
    + debian/additions/mysqld_safe_syslog.cnf: Dropped, unused now with upstart.
    + debian/additons/my.cnf: Remove pid declaration and setup error logging to /var/log/mysql since
      we're not piping anything around logger anymore.
    + debian/rules, debian/mysql-server-5.1.logcheck.ignore.{paranoid,worstation},
      debian/mysql-server-5.1.logcheck.ignore.server: : Remove references to mysqld_safe
    + debian/patches/38_scripts_mysqld_safe.sh_signals.dpatch: Dropped
  * Added -fno-strict-aliasing to CFLAGS to get around mysql testsuite build failures.
  * Add Apport hook (LP: #354188):
    + debian/mysql-server-5.1.py: apport package hook
    + debian/rules: Make it installable
  * debian/mysql-server-5.1.mysql-server.logrotate: Check to see if mysql is running before
    running logrotate. (LP: #513135)
  * Make the testsuite installable. (LP: #530752)
    + debian/mysql-server-5.1.files, debian/rules: install apport package hook
  * debian/mysql-server-5.1.preinst: Set mysql user's home directory
    to /nonexistent to protect against having the /var/lib/mysql
    user-writeable. If an attacker can trick mysqld into creating
    dot files in the home directory, he could do .rhost-like attacks
    on the system. (LP: #293258)
  * debian/control: mysql-client-5.1 should depend on mysql-core-client-5.1.
    (LP: #590952) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--source include/have_innodb_plugin.inc
 
2
 
 
3
--echo #
 
4
--echo # Bug #40113: Embedded SELECT inside UPDATE or DELETE can timeout 
 
5
--echo #  without error
 
6
--echo #
 
7
 
 
8
CREATE TABLE t1 (a int, b int, PRIMARY KEY  (a,b)) ENGINE=InnoDB;
 
9
 
 
10
INSERT INTO t1 (a,b) VALUES (1070109,99);
 
11
 
 
12
CREATE TABLE t2 (b int, a int, PRIMARY KEY (b)) ENGINE=InnoDB;
 
13
 
 
14
INSERT INTO t2 (b,a) VALUES (7,1070109);
 
15
 
 
16
SELECT * FROM t1;
 
17
 
 
18
BEGIN;
 
19
 
 
20
SELECT b FROM t2 WHERE b=7 FOR UPDATE;
 
21
 
 
22
CONNECT (addconroot, localhost, root,,);
 
23
CONNECTION addconroot;
 
24
 
 
25
BEGIN;
 
26
 
 
27
--error ER_LOCK_WAIT_TIMEOUT
 
28
SELECT b FROM t2 WHERE b=7 FOR UPDATE;
 
29
 
 
30
--error ER_LOCK_WAIT_TIMEOUT
 
31
INSERT INTO t1 (a) VALUES ((SELECT a FROM t2 WHERE b=7));
 
32
 
 
33
--error ER_LOCK_WAIT_TIMEOUT
 
34
UPDATE t1 SET a='7000000' WHERE a=(SELECT a FROM t2 WHERE b=7);
 
35
 
 
36
--error ER_LOCK_WAIT_TIMEOUT
 
37
DELETE FROM t1 WHERE a=(SELECT a FROM t2 WHERE b=7);
 
38
 
 
39
SELECT * FROM t1;
 
40
 
 
41
CONNECTION default;
 
42
DISCONNECT addconroot;
 
43
 
 
44
DROP TABLE t2, t1;
 
45
 
 
46
--echo # End of 5.0 tests
 
47
 
 
48
--echo #
 
49
--echo # Bug#46539 Various crashes on INSERT IGNORE SELECT + SELECT
 
50
--echo #           FOR UPDATE
 
51
--echo #
 
52
--disable_warnings
 
53
drop table if exists t1;
 
54
--enable_warnings
 
55
create table t1 (a int primary key auto_increment,
 
56
                 b int, index(b)) engine=innodb;
 
57
insert into t1 (b) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
 
58
set autocommit=0;
 
59
begin;
 
60
select * from t1 where b=5 for update;
 
61
connect (con1, localhost, root,,);
 
62
connection con1;
 
63
--error ER_LOCK_WAIT_TIMEOUT
 
64
insert ignore into t1 (b) select a as b from t1;
 
65
connection default;
 
66
--echo # Cleanup
 
67
--echo #
 
68
disconnect con1;
 
69
commit;
 
70
set autocommit=default;
 
71
drop table t1;
 
72
 
 
73
--echo #
 
74
--echo # Bug #37183 insert ignore into .. select ... hangs 
 
75
--echo #            after deadlock was encountered
 
76
--echo #
 
77
connect (con1,localhost,root,,);
 
78
create table t1(id int primary key,v int)engine=innodb;
 
79
insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
 
80
create table t2 like t1;
 
81
 
 
82
--connection con1
 
83
begin;
 
84
update t1 set v=id*2 where id=1;
 
85
 
 
86
--connection default
 
87
begin;
 
88
update t1 set v=id*2 where id=2;
 
89
 
 
90
--connection con1
 
91
--error 1205
 
92
update t1 set v=id*2 where id=2;
 
93
 
 
94
--connection default
 
95
--error 1205
 
96
insert ignore into t2 select * from t1 where id=1; 
 
97
rollback;
 
98
 
 
99
--connection con1
 
100
rollback;
 
101
 
 
102
--connection default
 
103
disconnect con1;
 
104
drop table t1, t2;
 
105
 
 
106
 
 
107
--echo #
 
108
--echo # Bug#41756 Strange error messages about locks from InnoDB
 
109
--echo #
 
110
--disable_warnings
 
111
drop table if exists t1;
 
112
--enable_warnings
 
113
--echo # In the default transaction isolation mode, and/or with
 
114
--echo # innodb_locks_unsafe_for_binlog=OFF, handler::unlock_row()
 
115
--echo # in InnoDB does nothing.
 
116
--echo # Thus in order to reproduce the condition that led to the
 
117
--echo # warning, one needs to relax isolation by either
 
118
--echo # setting a weaker tx_isolation value, or by turning on
 
119
--echo # the unsafe replication switch.
 
120
--echo # For testing purposes, choose to tweak the isolation level,
 
121
--echo # since it's settable at runtime, unlike
 
122
--echo # innodb_locks_unsafe_for_binlog, which is
 
123
--echo # only a command-line switch.
 
124
--echo #
 
125
set @@session.tx_isolation="read-committed";
 
126
 
 
127
--echo # Prepare data. We need a table with a unique index,
 
128
--echo # for join_read_key to be used. The other column
 
129
--echo # allows to control what passes WHERE clause filter.
 
130
create table t1 (a int primary key, b int) engine=innodb;
 
131
--echo # Let's make sure t1 has sufficient amount of rows
 
132
--echo # to exclude JT_ALL access method when reading it,
 
133
--echo # i.e. make sure that JT_EQ_REF(a) is always preferred.
 
134
insert into t1 values (1,1), (2,null), (3,1), (4,1),
 
135
                      (5,1), (6,1), (7,1), (8,1), (9,1), (10,1),
 
136
                      (11,1), (12,1), (13,1), (14,1), (15,1),
 
137
                      (16,1), (17,1), (18,1), (19,1), (20,1);
 
138
--echo #
 
139
--echo # Demonstrate that for the SELECT statement
 
140
--echo # used later in the test JT_EQ_REF access method is used.
 
141
--echo #
 
142
--vertical_results
 
143
explain
 
144
select 1 from t1 natural join (select 2 as a, 1 as b union all
 
145
                               select 2 as a, 2 as b) as t2 for update;
 
146
--horizontal_results
 
147
--echo #
 
148
--echo # Demonstrate that the reported SELECT statement
 
149
--echo # no longer produces warnings.
 
150
--echo #
 
151
select 1 from t1 natural join (select 2 as a, 1 as b union all
 
152
                               select 2 as a, 2 as b) as t2 for update;
 
153
commit;
 
154
--echo # 
 
155
--echo # Demonstrate that due to lack of inter-sweep "reset" function,
 
156
--echo # we keep some non-matching records locked, even though we know
 
157
--echo # we could unlock them.
 
158
--echo # To do that, show that if there is only one distinct value
 
159
--echo # for a in t2 (a=2), we will keep record (2,null) in t1 locked.
 
160
--echo # But if we add another value for "a" to t2, say 6,
 
161
--echo # join_read_key cache will be pruned at least once, 
 
162
--echo # and thus record (2, null) in t1 will get unlocked.
 
163
--echo #
 
164
begin;
 
165
select 1 from t1 natural join (select 2 as a, 1 as b union all
 
166
                               select 2 as a, 2 as b) as t2 for update;
 
167
connect (con1,localhost,root,,);
 
168
--echo #
 
169
--echo # Switching to connection con1
 
170
connection con1;
 
171
--echo # We should be able to delete all records from t1 except (2, null),
 
172
--echo # since they were not locked.
 
173
begin;
 
174
--echo # Delete in series of 3 records so that full scan
 
175
--echo # is not used and we're not blocked on record (2,null)
 
176
delete from t1 where a in (1,3,4);
 
177
delete from t1 where a in (5,6,7);
 
178
delete from t1 where a in (8,9,10);
 
179
delete from t1 where a in (11,12,13);
 
180
delete from t1 where a in (14,15,16);
 
181
delete from t1 where a in (17,18);
 
182
delete from t1 where a in (19,20);
 
183
--echo # 
 
184
--echo # Record (2, null) is locked. This is actually unnecessary, 
 
185
--echo # because the previous select returned no rows. 
 
186
--echo # Just demonstrate the effect.
 
187
--echo #
 
188
--error ER_LOCK_WAIT_TIMEOUT
 
189
delete from t1;
 
190
rollback;
 
191
--echo #
 
192
--echo # Switching to connection default
 
193
connection default;
 
194
--echo #
 
195
--echo # Show that the original contents of t1 is intact:
 
196
select * from t1;
 
197
commit;
 
198
--echo #
 
199
--echo # Have a one more record in t2 to show that 
 
200
--echo # if join_read_key cache is purned, the current
 
201
--echo # row under the cursor is unlocked (provided, this row didn't 
 
202
--echo # match the partial WHERE clause, of course).
 
203
--echo # Sic: the result of this test dependent on the order of retrieval
 
204
--echo # of records --echo # from the derived table, if !
 
205
--echo # We use DELETE to disable the JOIN CACHE. This DELETE modifies no
 
206
--echo # records. It also should leave no InnoDB row locks.
 
207
--echo #
 
208
begin;
 
209
delete t1.* from t1 natural join (select 2 as a, 2 as b union all
 
210
                                  select 0 as a, 0 as b) as t2;
 
211
--echo # Demonstrate that nothing was deleted form t1
 
212
select * from t1;
 
213
--echo #
 
214
--echo # Switching to connection con1
 
215
connection con1;
 
216
begin;
 
217
--echo # Since there is another distinct record in the derived table
 
218
--echo # the previous matching record in t1 -- (2,null) -- was unlocked.
 
219
delete from t1;
 
220
--echo # We will need the contents of the table again.
 
221
rollback;
 
222
select * from t1;
 
223
commit;
 
224
--echo #
 
225
--echo # Switching to connection default
 
226
connection default;
 
227
rollback;
 
228
begin;
 
229
--echo #
 
230
--echo # Before this patch, we could wrongly unlock a record
 
231
--echo # that was cached and later used in a join. Demonstrate that
 
232
--echo # this is no longer the case.
 
233
--echo # Sic: this test is also order-dependent (i.e. the
 
234
--echo # the bug would show up only if the first record in the union
 
235
--echo # is retreived and processed first.
 
236
--echo #
 
237
--echo # Verify that JT_EQ_REF is used.
 
238
--vertical_results
 
239
explain
 
240
select 1 from t1 natural join (select 3 as a, 2 as b union all
 
241
                               select 3 as a, 1 as b) as t2 for update;
 
242
--horizontal_results
 
243
--echo # Lock the record.
 
244
select 1 from t1 natural join (select 3 as a, 2 as b union all
 
245
                               select 3 as a, 1 as b) as t2 for update;
 
246
--echo # Switching to connection con1
 
247
connection con1;
 
248
--echo #
 
249
--echo # We should not be able to delete record (3,1) from t1,
 
250
--echo # (previously it was possible).
 
251
--echo #
 
252
--error ER_LOCK_WAIT_TIMEOUT
 
253
delete from t1 where a=3;
 
254
--echo # Switching to connection default
 
255
connection default;
 
256
commit;
 
257
 
 
258
disconnect con1;
 
259
set @@session.tx_isolation=default;
 
260
drop table t1;
 
261
 
 
262
--echo #
 
263
--echo # End of 5.1 tests
 
264
--echo #