1
drop table if exists t1,t2;
2
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;
3
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
5
select dummy1,count(distinct id) from t1 group by dummy1;
6
dummy1 count(distinct id)
8
update t1 set id=-1 where id=1;
10
update t1 set id=1 where id=1;
11
ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
12
create table t2 SELECT * from t1;
13
ERROR HY000: Table 't2' was not locked with LOCK TABLES
14
create temporary table t2 SELECT * from t1;
15
drop table if exists t2;
17
create table t2 SELECT * from t1;
18
LOCK TABLE t1 WRITE,t2 write;
19
insert into t2 SELECT * from t1;
20
update t1 set id=1 where id=-1;
23
index1 smallint(6) default NULL,
24
nr smallint(6) default NULL,
28
nr smallint(6) default NULL,
29
name varchar(20) default NULL
31
INSERT INTO t2 VALUES (1,'item1');
32
INSERT INTO t2 VALUES (2,'item2');
33
lock tables t1 write, t2 read;
34
insert into t1 select 1,nr from t2 where name='item1';
35
insert into t1 select 2,nr from t2 where name='item2';
38
Table Op Msg_type Msg_text
39
test.t1 check status OK
42
Table Op Msg_type Msg_text
43
test.t2 check Error Table 't2' was not locked with LOCK TABLES
44
test.t2 check status OK
45
insert into t1 select index1,nr from t1;
46
ERROR HY000: Table 't1' was not locked with LOCK TABLES
48
lock tables t1 write, t1 as t1_alias read;
49
insert into t1 select index1,nr from t1 as t1_alias;
51
ERROR HY000: Table 't2' was not locked with LOCK TABLES
54
create table t1 (c1 int);
55
create table t2 (c1 int);
56
create table t3 (c1 int);
57
lock tables t1 write, t2 write, t3 write;
58
drop table t2, t3, t1;
59
create table t1 (c1 int);
60
create table t2 (c1 int);
61
create table t3 (c1 int);
62
lock tables t1 write, t2 write, t3 write, t1 as t4 read;
63
alter table t2 add column c2 int;
64
drop table t1, t2, t3;
65
create table t1 ( a int(11) not null auto_increment, primary key(a));
66
create table t2 ( a int(11) not null auto_increment, primary key(a));
67
lock tables t1 write, t2 read;
68
delete from t1 using t1,t2 where t1.a=t2.a;
69
delete t1 from t1,t2 where t1.a=t2.a;
70
delete from t2 using t1,t2 where t1.a=t2.a;
71
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
72
delete t2 from t1,t2 where t1.a=t2.a;
73
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
75
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
79
drop table if exists t1;
80
create table t1 (a int);
82
flush tables with read lock;
83
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
86
DROP TABLE IF EXISTS t1;
87
CREATE TABLE t1 (i INT);
88
LOCK TABLES mysql.time_zone READ, t1 READ;
90
LOCK TABLES mysql.time_zone READ, t1 WRITE;
92
LOCK TABLES mysql.time_zone READ;
94
LOCK TABLES mysql.time_zone WRITE;
96
LOCK TABLES mysql.time_zone READ, t1 READ;
97
LOCK TABLES mysql.time_zone WRITE, t1 READ;
98
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types
99
LOCK TABLES mysql.time_zone WRITE, t1 WRITE;
100
ERROR HY000: You can't combine write-locking of system tables with other tables or lock types