~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/innobase/mysql-test/innodb-lock.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#
3
 
# Check and select innodb lock type
4
 
#
5
 
 
6
 
set global innodb_table_locks=1;
7
 
 
8
 
select @@innodb_table_locks;
9
 
 
10
 
#
11
 
# Testing of explicit table locks with enforced table locks
12
 
#
13
 
 
14
 
connect (con1,localhost,root,,);
15
 
connect (con2,localhost,root,,);
16
 
 
17
 
--disable_warnings
18
 
drop table if exists t1;
19
 
--enable_warnings
20
 
 
21
 
#
22
 
# Testing of explicit table locks with enforced table locks
23
 
#
24
 
 
25
 
set @@innodb_table_locks=1;
26
 
 
27
 
connection con1;
28
 
create table t1 (id integer, x integer) engine=INNODB;
29
 
insert into t1 values(0, 0);
30
 
set autocommit=0;
31
 
SELECT * from t1 where id = 0 FOR UPDATE;
32
 
 
33
 
connection con2;
34
 
set autocommit=0;
35
 
 
36
 
# The following statement should hang because con1 is locking the page
37
 
--send
38
 
lock table t1 write;
39
 
--sleep 2
40
 
 
41
 
connection con1;
42
 
update t1 set x=1 where id = 0;
43
 
select * from t1;
44
 
commit;
45
 
 
46
 
connection con2;
47
 
reap;
48
 
update t1 set x=2 where id = 0;
49
 
commit;
50
 
unlock tables;
51
 
 
52
 
connection con1;
53
 
select * from t1;
54
 
commit;
55
 
 
56
 
drop table t1;
57
 
 
58
 
#
59
 
# Try with old lock method (where LOCK TABLE is ignored by InnoDB)
60
 
#
61
 
 
62
 
set @@innodb_table_locks=0;
63
 
 
64
 
create table t1 (id integer primary key, x integer) engine=INNODB;
65
 
insert into t1 values(0, 0),(1,1),(2,2);
66
 
commit;
67
 
SELECT * from t1 where id = 0 FOR UPDATE;
68
 
 
69
 
connection con2;
70
 
set autocommit=0;
71
 
set @@innodb_table_locks=0;
72
 
 
73
 
# The following statement should work becase innodb doesn't check table locks
74
 
lock table t1 write;
75
 
 
76
 
connection con1;
77
 
 
78
 
# This will be locked by MySQL
79
 
--send
80
 
update t1 set x=10 where id = 2;
81
 
--sleep 2
82
 
 
83
 
connection con2;
84
 
 
85
 
# Note that we will get a deadlock if we try to select any rows marked
86
 
# for update by con1 !
87
 
 
88
 
SELECT * from t1 where id = 2;
89
 
UPDATE t1 set x=3 where id = 2;
90
 
commit;
91
 
SELECT * from t1;
92
 
commit;
93
 
unlock tables;
94
 
 
95
 
connection con1;
96
 
reap;
97
 
commit;
98
 
select * from t1;
99
 
drop table t1;
100
 
 
101
 
# End of 4.1 tests