~vkolesnikov/pbxt/pbxt-07-diskfull

« back to all changes in this revision

Viewing changes to pbxt/mysql-test-update/mysql-test/t/lock.test

  • Committer: paul-mccullagh
  • Date: 2006-10-23 09:14:04 UTC
  • Revision ID: paul-mccullagh-918861e03d351978a9541168a96e58cc826734ee
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Testing of table locking
 
3
#
 
4
 
 
5
--disable_warnings
 
6
drop table if exists t1,t2;
 
7
--enable_warnings
 
8
CREATE TABLE t1 (  `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY  (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
 
9
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
 
10
LOCK TABLE t1 WRITE;
 
11
select dummy1,count(distinct id) from t1 group by dummy1;
 
12
update t1 set id=-1 where id=1;
 
13
LOCK TABLE t1 READ;
 
14
--error 1099
 
15
update t1 set id=1 where id=1;
 
16
--error 1100
 
17
create table t2 SELECT * from t1;
 
18
create temporary table t2 SELECT * from t1;
 
19
drop table if exists t2;
 
20
unlock tables;
 
21
create table t2 SELECT * from t1;
 
22
LOCK TABLE t1 WRITE,t2 write;
 
23
insert into t2 SELECT * from t1;
 
24
update t1 set id=1 where id=-1;
 
25
drop table t1,t2;
 
26
 
 
27
 
 
28
#
 
29
# Check bug with INSERT ... SELECT with lock tables
 
30
#
 
31
 
 
32
CREATE TABLE t1 (
 
33
  index1 smallint(6) default NULL,
 
34
  nr smallint(6) default NULL,
 
35
  KEY index1(index1)
 
36
) ENGINE=MyISAM;
 
37
 
 
38
CREATE TABLE t2 (
 
39
  nr smallint(6) default NULL,
 
40
  name varchar(20) default NULL
 
41
) ENGINE=MyISAM;
 
42
 
 
43
INSERT INTO t2 VALUES (1,'item1');
 
44
INSERT INTO t2 VALUES (2,'item2');
 
45
 
 
46
# problem begins here!
 
47
lock tables t1 write, t2 read;
 
48
insert into t1 select 1,nr from t2 where name='item1';
 
49
insert into t1 select 2,nr from t2 where name='item2';
 
50
unlock tables;
 
51
check table t1;
 
52
 
 
53
# Check error message
 
54
lock tables t1 write;
 
55
check table t2;
 
56
--error 1100
 
57
insert into t1 select index1,nr from t1;
 
58
unlock tables;
 
59
lock tables t1 write, t1 as t1_alias read;
 
60
insert into t1 select index1,nr from t1 as t1_alias;
 
61
drop table t1,t2;
 
62
 
 
63
#
 
64
# BUG#5390 - problems with merge tables
 
65
# Supplement test for the after-fix optimization
 
66
# Check that a dropped table is correctly removed from a lock.
 
67
create table t1 (c1 int);
 
68
create table t2 (c1 int);
 
69
create table t3 (c1 int);
 
70
lock tables t1 write, t2 write, t3 write;
 
71
# This removes one table after the other from the lock.
 
72
drop table t2, t3, t1;
 
73
#
 
74
# Check that a lock merge works.
 
75
create table t1 (c1 int);
 
76
create table t2 (c1 int);
 
77
create table t3 (c1 int);
 
78
lock tables t1 write, t2 write, t3 write, t1 as t4 read;
 
79
alter table t2 add column c2 int;
 
80
drop table t1, t2, t3;
 
81
 
 
82
# Bug7241 - Invalid response when DELETE .. USING and LOCK TABLES used.
 
83
#
 
84
create table t1 ( a int(11) not null auto_increment, primary key(a));
 
85
create table t2 ( a int(11) not null auto_increment, primary key(a));
 
86
lock tables t1 write, t2 read;
 
87
delete from t1 using t1,t2 where t1.a=t2.a;
 
88
delete t1 from t1,t2 where t1.a=t2.a;
 
89
--error 1099
 
90
delete from t2 using t1,t2 where t1.a=t2.a;
 
91
--error 1099
 
92
delete t2 from t1,t2 where t1.a=t2.a;
 
93
drop table t1,t2;
 
94
 
 
95
# End of 4.1 tests
 
96
 
 
97
#
 
98
# Bug#18884 "lock table + global read lock = crash"
 
99
# The bug is not repeatable, just add the test case.
 
100
#
 
101
--disable_warnings
 
102
drop table if exists t1;
 
103
--enable_warnings
 
104
create table t1 (a int);
 
105
lock table t1 write;
 
106
--error ER_LOCK_OR_ACTIVE_TRANSACTION
 
107
flush tables with read lock;
 
108
unlock tables;
 
109
drop table t1;
 
110