~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Testing of table locking
3
#
4
5
--disable_warnings
6
drop table if exists t1,t2;
7
--enable_warnings
223 by Brian Aker
Cleanup int() work.
8
CREATE TABLE t1 (  `id` int NOT NULL default '0', `id2` int NOT NULL default '0', `id3` int NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY  (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
1 by brian
clean slate
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 (
223 by Brian Aker
Cleanup int() work.
33
  index1 smallint default NULL,
34
  nr smallint default NULL,
1 by brian
clean slate
35
  KEY index1(index1)
36
) ENGINE=MyISAM;
37
38
CREATE TABLE t2 (
223 by Brian Aker
Cleanup int() work.
39
  nr smallint default NULL,
1 by brian
clean slate
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
--error ER_TABLE_NOT_LOCKED
62
drop table t1,t2;
63
unlock tables;
64
drop table t1,t2;
65
66
#
67
# BUG#5390 - problems with merge tables
68
# Supplement test for the after-fix optimization
69
# Check that a dropped table is correctly removed from a lock.
70
create table t1 (c1 int);
71
create table t2 (c1 int);
72
create table t3 (c1 int);
73
lock tables t1 write, t2 write, t3 write;
74
# This removes one table after the other from the lock.
75
drop table t2, t3, t1;
76
#
77
# Check that a lock merge works.
78
create table t1 (c1 int);
79
create table t2 (c1 int);
80
create table t3 (c1 int);
81
lock tables t1 write, t2 write, t3 write, t1 as t4 read;
82
alter table t2 add column c2 int;
83
drop table t1, t2, t3;
84
85
# Bug7241 - Invalid response when DELETE .. USING and LOCK TABLES used.
86
#
223 by Brian Aker
Cleanup int() work.
87
create table t1 ( a int not null auto_increment, primary key(a));
88
create table t2 ( a int not null auto_increment, primary key(a));
1 by brian
clean slate
89
lock tables t1 write, t2 read;
90
delete from t1 using t1,t2 where t1.a=t2.a;
91
delete t1 from t1,t2 where t1.a=t2.a;
92
--error 1099
93
delete from t2 using t1,t2 where t1.a=t2.a;
94
--error 1099
95
delete t2 from t1,t2 where t1.a=t2.a;
96
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
97
drop table t1,t2;
98
unlock tables;
99
drop table t2,t1;
100
101
--echo End of 4.1 tests.
102
103
104
#
105
# Bug#18884 "lock table + global read lock = crash"
106
# The bug is not repeatable, just add the test case.
107
#
108
--disable_warnings
109
drop table if exists t1;
110
--enable_warnings
111
create table t1 (a int);
112
lock table t1 write;
113
--error ER_LOCK_OR_ACTIVE_TRANSACTION
114
flush tables with read lock;
115
unlock tables;
116
drop table t1;
117
118
119
--echo
120
--echo Cleanup.
121
--echo
122
123
--echo End of 5.1 tests.