2001-10-03 23:19:58 +02:00
|
|
|
drop table if exists t1,t2,t3,t4,t5,t6;
|
2003-06-27 15:29:10 +02:00
|
|
|
drop database if exists mysqltest;
|
2001-09-28 07:05:54 +02:00
|
|
|
create table t1 (a int not null primary key auto_increment, message char(20));
|
|
|
|
create table t2 (a int not null primary key auto_increment, message char(20));
|
|
|
|
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
|
|
|
|
INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(t1,t2);
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t3;
|
2000-12-28 02:56:38 +01:00
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
3 t1
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
3 t2
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t3 order by a desc;
|
2000-12-28 02:56:38 +01:00
|
|
|
a b
|
|
|
|
3 t1
|
|
|
|
3 t2
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t3;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
|
|
|
insert into t2 select NULL,message from t1;
|
|
|
|
insert into t1 select NULL,message from t2;
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,test.t2);
|
2001-09-28 07:05:54 +02:00
|
|
|
explain select * from t3 where a < 10;
|
2002-09-26 22:08:22 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2002-11-21 21:25:53 +01:00
|
|
|
1 SIMPLE t3 range a a 4 NULL 18 Using where
|
2001-09-28 07:05:54 +02:00
|
|
|
explain select * from t3 where a > 10 and a < 20;
|
2002-09-26 22:08:22 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2005-05-13 11:08:08 +02:00
|
|
|
1 SIMPLE t3 range a a 4 NULL 17 Using where
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t3 where a = 10;
|
2000-12-28 02:56:38 +01:00
|
|
|
a b
|
|
|
|
10 Testing
|
|
|
|
10 Testing
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t3 where a < 10;
|
2000-12-28 02:56:38 +01:00
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
3 t1
|
|
|
|
3 t2
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
6 t2
|
2006-02-11 19:51:43 +01:00
|
|
|
6 t1
|
2000-12-28 02:56:38 +01:00
|
|
|
7 Testing
|
|
|
|
7 Testing
|
|
|
|
8 table
|
|
|
|
8 table
|
|
|
|
9 t2
|
|
|
|
9 t2
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t3 where a > 10 and a < 20;
|
2000-12-28 02:56:38 +01:00
|
|
|
a b
|
|
|
|
11 table
|
|
|
|
11 table
|
|
|
|
12 t1
|
|
|
|
12 t1
|
|
|
|
13 Testing
|
|
|
|
13 Testing
|
|
|
|
14 table
|
|
|
|
14 table
|
|
|
|
15 t2
|
|
|
|
15 t2
|
|
|
|
16 Testing
|
|
|
|
16 Testing
|
|
|
|
17 table
|
|
|
|
17 table
|
|
|
|
18 t2
|
|
|
|
18 t2
|
|
|
|
19 Testing
|
|
|
|
19 Testing
|
2001-09-28 07:05:54 +02:00
|
|
|
explain select a from t3 order by a desc limit 10;
|
2002-09-26 22:08:22 +02:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2002-10-03 17:47:04 +02:00
|
|
|
1 SIMPLE t3 index NULL a 4 NULL 1131 Using index
|
2001-09-28 07:05:54 +02:00
|
|
|
select a from t3 order by a desc limit 10;
|
2000-12-28 02:56:38 +01:00
|
|
|
a
|
|
|
|
699
|
|
|
|
698
|
|
|
|
697
|
|
|
|
696
|
|
|
|
695
|
|
|
|
694
|
|
|
|
693
|
|
|
|
692
|
|
|
|
691
|
|
|
|
690
|
2001-09-28 07:05:54 +02:00
|
|
|
select a from t3 order by a desc limit 300,10;
|
2000-12-28 02:56:38 +01:00
|
|
|
a
|
|
|
|
416
|
|
|
|
415
|
|
|
|
415
|
|
|
|
414
|
|
|
|
414
|
|
|
|
413
|
|
|
|
413
|
|
|
|
412
|
|
|
|
412
|
|
|
|
411
|
2001-10-03 23:19:58 +02:00
|
|
|
delete from t3 where a=3;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
6 t2
|
|
|
|
6 t1
|
|
|
|
7 Testing
|
|
|
|
7 Testing
|
|
|
|
8 table
|
|
|
|
8 table
|
|
|
|
9 t2
|
|
|
|
9 t2
|
|
|
|
delete from t3 where a >= 6 and a <= 8;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
9 t2
|
|
|
|
9 t2
|
|
|
|
update t3 set a=3 where a=9;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
3 t2
|
|
|
|
3 t2
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
|
|
|
update t3 set a=6 where a=7;
|
|
|
|
select * from t3 where a < 10;
|
|
|
|
a b
|
|
|
|
1 Testing
|
|
|
|
1 Testing
|
|
|
|
2 table
|
|
|
|
2 table
|
|
|
|
3 t2
|
|
|
|
3 t2
|
|
|
|
4 Testing
|
|
|
|
4 Testing
|
|
|
|
5 table
|
|
|
|
5 table
|
2001-09-28 07:05:54 +02:00
|
|
|
show create table t3;
|
2001-02-17 18:04:33 +01:00
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
2003-01-14 13:28:36 +01:00
|
|
|
`b` char(20) default NULL,
|
2001-02-17 18:04:33 +01:00
|
|
|
KEY `a` (`a`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
|
|
|
create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2);
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t4;
|
2006-10-06 07:54:47 +02:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2003-06-27 15:29:10 +02:00
|
|
|
alter table t4 add column c int;
|
2006-10-06 07:54:47 +02:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2003-06-27 15:29:10 +02:00
|
|
|
create database mysqltest;
|
|
|
|
create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6);
|
2003-06-27 15:29:10 +02:00
|
|
|
show create table t5;
|
|
|
|
Table Create Table
|
|
|
|
t5 CREATE TABLE `t5` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
2003-06-27 15:29:10 +02:00
|
|
|
`b` char(20) default NULL,
|
|
|
|
KEY `a` (`a`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`mysqltest`.`t6`)
|
|
|
|
alter table t5 engine=myisam;
|
2003-06-27 15:29:10 +02:00
|
|
|
drop table t5, mysqltest.t6;
|
|
|
|
drop database mysqltest;
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t4,t3,t1,t2;
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t1 (c char(10)) engine=myisam;
|
|
|
|
create table t2 (c char(10)) engine=myisam;
|
|
|
|
create table t3 (c char(10)) union=(t1,t2) engine=merge;
|
2001-09-28 07:05:54 +02:00
|
|
|
insert into t1 (c) values ('test1');
|
|
|
|
insert into t1 (c) values ('test1');
|
|
|
|
insert into t1 (c) values ('test1');
|
|
|
|
insert into t2 (c) values ('test2');
|
|
|
|
insert into t2 (c) values ('test2');
|
|
|
|
insert into t2 (c) values ('test2');
|
|
|
|
select * from t3;
|
2000-12-28 02:56:38 +01:00
|
|
|
c
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test2
|
|
|
|
test2
|
|
|
|
test2
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t3;
|
2000-12-28 02:56:38 +01:00
|
|
|
c
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test1
|
|
|
|
test2
|
|
|
|
test2
|
|
|
|
test2
|
2001-09-28 07:05:54 +02:00
|
|
|
delete from t3 where 1=1;
|
|
|
|
select * from t3;
|
2000-12-28 02:56:38 +01:00
|
|
|
c
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t1;
|
2000-12-28 02:56:38 +01:00
|
|
|
c
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t3,t2,t1;
|
|
|
|
CREATE TABLE t1 (incr int not null, othr int not null, primary key(incr));
|
|
|
|
CREATE TABLE t2 (incr int not null, othr int not null, primary key(incr));
|
|
|
|
CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr))
|
2003-12-10 05:31:42 +01:00
|
|
|
ENGINE=MERGE UNION=(t1,t2);
|
2001-09-28 07:05:54 +02:00
|
|
|
SELECT * from t3;
|
2000-12-28 02:56:38 +01:00
|
|
|
incr othr
|
2001-09-28 07:05:54 +02:00
|
|
|
INSERT INTO t1 VALUES ( 1,10),( 3,53),( 5,21),( 7,12),( 9,17);
|
|
|
|
INSERT INTO t2 VALUES ( 2,24),( 4,33),( 6,41),( 8,26),( 0,32);
|
|
|
|
INSERT INTO t1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37);
|
|
|
|
INSERT INTO t2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30);
|
|
|
|
SELECT * from t3 where incr in (1,2,3,4) order by othr;
|
2000-12-28 02:56:38 +01:00
|
|
|
incr othr
|
|
|
|
1 10
|
|
|
|
2 24
|
|
|
|
4 33
|
|
|
|
3 53
|
2001-09-28 07:05:54 +02:00
|
|
|
alter table t3 UNION=(t1);
|
|
|
|
select count(*) from t3;
|
2001-01-28 20:35:50 +01:00
|
|
|
count(*)
|
|
|
|
10
|
2001-09-28 07:05:54 +02:00
|
|
|
alter table t3 UNION=(t1,t2);
|
|
|
|
select count(*) from t3;
|
2001-01-28 20:35:50 +01:00
|
|
|
count(*)
|
|
|
|
20
|
2003-12-10 05:31:42 +01:00
|
|
|
alter table t3 ENGINE=MYISAM;
|
2001-09-28 07:05:54 +02:00
|
|
|
select count(*) from t3;
|
2001-01-28 20:35:50 +01:00
|
|
|
count(*)
|
|
|
|
20
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t3;
|
|
|
|
CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr))
|
2003-12-10 05:31:42 +01:00
|
|
|
ENGINE=MERGE UNION=(t1,t2);
|
2001-09-28 07:05:54 +02:00
|
|
|
show create table t3;
|
2001-03-06 14:24:08 +01:00
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`incr` int(11) NOT NULL,
|
|
|
|
`othr` int(11) NOT NULL,
|
2001-03-06 14:24:08 +01:00
|
|
|
PRIMARY KEY (`incr`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
2001-09-28 07:05:54 +02:00
|
|
|
alter table t3 drop primary key;
|
|
|
|
show create table t3;
|
2001-03-06 14:24:08 +01:00
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`incr` int(11) NOT NULL,
|
|
|
|
`othr` int(11) NOT NULL
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t3,t2,t1;
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t1 (a int not null, key(a)) engine=merge;
|
2001-09-28 07:05:54 +02:00
|
|
|
select * from t1;
|
2001-01-21 15:30:16 +01:00
|
|
|
a
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t1;
|
|
|
|
create table t1 (a int not null, b int not null, key(a,b));
|
|
|
|
create table t2 (a int not null, b int not null, key(a,b));
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2);
|
2001-09-28 07:05:54 +02:00
|
|
|
insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6);
|
|
|
|
insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
|
|
|
|
flush tables;
|
|
|
|
select * from t3 where a=1 order by b limit 2;
|
2001-05-16 23:06:30 +02:00
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
2001-09-28 07:05:54 +02:00
|
|
|
drop table t3,t1,t2;
|
2002-07-21 23:55:32 +02:00
|
|
|
create table t1 (a int not null, b int not null auto_increment, primary key(a,b));
|
|
|
|
create table t2 (a int not null, b int not null auto_increment, primary key(a,b));
|
2001-10-03 23:19:58 +02:00
|
|
|
create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO;
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t4 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=NO;
|
|
|
|
create table t5 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
|
|
|
|
create table t6 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
|
2001-10-03 23:19:58 +02:00
|
|
|
show create table t3;
|
|
|
|
Table Create Table
|
|
|
|
t3 CREATE TABLE `t3` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 23:19:58 +02:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
2001-10-03 23:19:58 +02:00
|
|
|
show create table t4;
|
|
|
|
Table Create Table
|
|
|
|
t4 CREATE TABLE `t4` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 23:19:58 +02:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
|
2001-10-03 23:19:58 +02:00
|
|
|
show create table t5;
|
|
|
|
Table Create Table
|
|
|
|
t5 CREATE TABLE `t5` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
2002-07-21 23:55:32 +02:00
|
|
|
`b` int(11) NOT NULL auto_increment,
|
|
|
|
PRIMARY KEY (`a`,`b`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`)
|
2001-10-03 23:19:58 +02:00
|
|
|
show create table t6;
|
|
|
|
Table Create Table
|
|
|
|
t6 CREATE TABLE `t6` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
2002-07-21 23:55:32 +02:00
|
|
|
`b` int(11) NOT NULL auto_increment,
|
|
|
|
PRIMARY KEY (`a`,`b`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
|
2002-07-21 23:55:32 +02:00
|
|
|
insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL);
|
|
|
|
insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL);
|
2001-10-03 23:19:58 +02:00
|
|
|
select * from t3 order by b,a limit 3;
|
|
|
|
a b
|
|
|
|
select * from t4 order by b,a limit 3;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
2 1
|
|
|
|
1 2
|
|
|
|
select * from t5 order by b,a limit 3,3;
|
|
|
|
a b
|
|
|
|
2 2
|
|
|
|
1 3
|
|
|
|
2 3
|
|
|
|
select * from t6 order by b,a limit 6,3;
|
|
|
|
a b
|
|
|
|
1 4
|
|
|
|
2 4
|
|
|
|
insert into t5 values (5,1),(5,2);
|
|
|
|
insert into t6 values (6,1),(6,2);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
a b
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
insert into t3 values (3,1),(3,2),(3,3),(3,4);
|
|
|
|
select * from t3 order by a,b;
|
|
|
|
a b
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
alter table t4 UNION=(t1,t2,t3);
|
|
|
|
show create table t4;
|
|
|
|
Table Create Table
|
|
|
|
t4 CREATE TABLE `t4` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 23:19:58 +02:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`,`t3`)
|
2001-10-03 23:19:58 +02:00
|
|
|
select * from t4 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
alter table t4 INSERT_METHOD=FIRST;
|
|
|
|
show create table t4;
|
|
|
|
Table Create Table
|
|
|
|
t4 CREATE TABLE `t4` (
|
2004-10-02 21:20:08 +02:00
|
|
|
`a` int(11) NOT NULL,
|
|
|
|
`b` int(11) NOT NULL,
|
2001-10-03 23:19:58 +02:00
|
|
|
KEY `a` (`a`,`b`)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`,`t3`)
|
2001-10-03 23:19:58 +02:00
|
|
|
insert into t4 values (4,1),(4,2);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
a b
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
select * from t3 order by a,b;
|
|
|
|
a b
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
select * from t4 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
3 1
|
|
|
|
3 2
|
|
|
|
3 3
|
|
|
|
3 4
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
select * from t5 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
6 1
|
|
|
|
6 2
|
2002-07-21 23:55:32 +02:00
|
|
|
select 1;
|
|
|
|
1
|
|
|
|
1
|
|
|
|
insert into t5 values (1,NULL),(5,NULL);
|
|
|
|
insert into t6 values (2,NULL),(6,NULL);
|
|
|
|
select * from t1 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
5 3
|
|
|
|
select * from t2 order by a,b;
|
|
|
|
a b
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
6 3
|
|
|
|
select * from t5 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
5 3
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
6 3
|
|
|
|
select * from t6 order by a,b;
|
|
|
|
a b
|
|
|
|
1 1
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
2 1
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
4 1
|
|
|
|
4 2
|
|
|
|
5 1
|
|
|
|
5 2
|
|
|
|
5 3
|
|
|
|
6 1
|
|
|
|
6 2
|
|
|
|
6 3
|
2003-07-01 14:49:32 +02:00
|
|
|
insert into t1 values (99,NULL);
|
|
|
|
select * from t4 where a+0 > 90;
|
|
|
|
a b
|
|
|
|
99 1
|
2004-06-25 15:12:13 +02:00
|
|
|
insert t5 values (1,1);
|
|
|
|
ERROR 23000: Duplicate entry '1-1' for key 1
|
|
|
|
insert t6 values (2,1);
|
|
|
|
ERROR 23000: Duplicate entry '2-1' for key 1
|
|
|
|
insert t5 values (1,1) on duplicate key update b=b+10;
|
|
|
|
insert t6 values (2,1) on duplicate key update b=b+20;
|
|
|
|
select * from t5 where a < 3;
|
|
|
|
a b
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
1 4
|
|
|
|
1 5
|
|
|
|
1 11
|
|
|
|
2 2
|
|
|
|
2 3
|
|
|
|
2 4
|
|
|
|
2 5
|
|
|
|
2 21
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t6, t5, t4, t3, t2, t1;
|
2003-12-10 05:31:42 +01:00
|
|
|
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM;
|
2002-06-15 19:59:42 +02:00
|
|
|
INSERT INTO t1 VALUES (1,1), (2,1);
|
2003-12-10 05:31:42 +01:00
|
|
|
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM;
|
2002-06-15 19:59:42 +02:00
|
|
|
INSERT INTO t2 VALUES (1,2), (2,2);
|
2003-12-10 05:31:42 +01:00
|
|
|
CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) ENGINE=MRG_MyISAM UNION=(t1,t2);
|
2003-01-06 00:48:59 +01:00
|
|
|
select max(b) from t3 where a = 2;
|
2002-06-15 19:59:42 +02:00
|
|
|
max(b)
|
2003-01-17 12:48:23 +01:00
|
|
|
2
|
2002-06-18 16:38:06 +02:00
|
|
|
select max(b) from t1 where a = 2;
|
|
|
|
max(b)
|
|
|
|
1
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t3,t1,t2;
|
2002-11-05 18:38:27 +01:00
|
|
|
create table t1 (a int not null);
|
|
|
|
create table t2 (a int not null);
|
|
|
|
insert into t1 values (1);
|
|
|
|
insert into t2 values (2);
|
2003-12-10 05:31:42 +01:00
|
|
|
create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2);
|
2002-11-05 18:38:27 +01:00
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
create temporary table t4 (a int not null);
|
|
|
|
create temporary table t5 (a int not null);
|
|
|
|
insert into t4 values (1);
|
|
|
|
insert into t5 values (2);
|
2003-12-10 05:31:42 +01:00
|
|
|
create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5);
|
2002-11-05 18:38:27 +01:00
|
|
|
select * from t6;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
2003-07-01 14:49:32 +02:00
|
|
|
drop table t6, t3, t1, t2, t4, t5;
|
2002-11-17 18:58:03 +01:00
|
|
|
CREATE TABLE t1 (
|
|
|
|
fileset_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
file_code varchar(32) NOT NULL default '',
|
|
|
|
fileset_root_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
PRIMARY KEY (fileset_id,file_code),
|
|
|
|
KEY files (fileset_id,fileset_root_id)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MyISAM;
|
2002-11-17 18:58:03 +01:00
|
|
|
INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1),
|
|
|
|
(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1),
|
|
|
|
(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1);
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
fileset_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
file_code varchar(32) NOT NULL default '',
|
|
|
|
fileset_root_id tinyint(3) unsigned NOT NULL default '0',
|
|
|
|
PRIMARY KEY (fileset_id,file_code),
|
|
|
|
KEY files (fileset_id,fileset_root_id)
|
2003-12-10 05:31:42 +01:00
|
|
|
) ENGINE=MRG_MyISAM UNION=(t1);
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
2002-11-21 21:25:53 +01:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-12-06 01:00:37 +01:00
|
|
|
1 SIMPLE t2 range PRIMARY PRIMARY 35 NULL 5 Using where
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
2002-11-21 21:25:53 +01:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-12-06 01:00:37 +01:00
|
|
|
1 SIMPLE t2 range PRIMARY,files PRIMARY 35 NULL 5 Using where
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
|
|
|
|
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
|
2002-11-21 21:25:53 +01:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2004-12-06 01:00:37 +01:00
|
|
|
1 SIMPLE t1 range PRIMARY,files PRIMARY 35 NULL 5 Using where
|
2002-11-17 18:58:03 +01:00
|
|
|
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
|
|
|
|
AND file_code = '0000000115' LIMIT 1;
|
2002-11-21 21:25:53 +01:00
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2006-10-16 17:09:58 +02:00
|
|
|
1 SIMPLE t2 const PRIMARY,files PRIMARY 35 const,const 1
|
2003-01-06 00:48:59 +01:00
|
|
|
DROP TABLE t2, t1;
|
2003-07-03 10:55:36 +02:00
|
|
|
create table t1 (x int, y int, index xy(x, y));
|
|
|
|
create table t2 (x int, y int, index xy(x, y));
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t3 (x int, y int, index xy(x, y)) engine=merge union=(t1,t2);
|
2003-07-03 10:55:36 +02:00
|
|
|
insert into t1 values(1, 2);
|
|
|
|
insert into t2 values(1, 3);
|
|
|
|
select * from t3 where x = 1 and y < 5 order by y;
|
|
|
|
x y
|
|
|
|
1 2
|
|
|
|
1 3
|
|
|
|
select * from t3 where x = 1 and y < 5 order by y desc;
|
|
|
|
x y
|
2003-07-04 14:42:57 +02:00
|
|
|
1 3
|
|
|
|
1 2
|
2003-07-03 10:55:36 +02:00
|
|
|
drop table t1,t2,t3;
|
2004-08-27 13:43:01 +02:00
|
|
|
create table t1 (a int);
|
|
|
|
create table t2 (a int);
|
|
|
|
insert into t1 values (0);
|
|
|
|
insert into t2 values (1);
|
|
|
|
create table t3 engine=merge union=(t1, t2) select * from t1;
|
2004-09-05 01:31:11 +02:00
|
|
|
ERROR HY000: You can't specify target table 't1' for update in FROM clause
|
2004-08-27 13:43:01 +02:00
|
|
|
create table t3 engine=merge union=(t1, t2) select * from t2;
|
2004-09-05 01:31:11 +02:00
|
|
|
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
2004-09-10 12:09:27 +02:00
|
|
|
create table t3 engine=merge union=(t1, t2) select (select max(a) from t2);
|
|
|
|
ERROR HY000: You can't specify target table 't2' for update in FROM clause
|
2004-08-27 13:43:01 +02:00
|
|
|
drop table t1, t2;
|
2005-09-23 10:15:11 +02:00
|
|
|
create table t1 (
|
2005-09-27 15:26:16 +02:00
|
|
|
a double(14,4),
|
2005-09-23 10:15:11 +02:00
|
|
|
b varchar(10),
|
|
|
|
index (a,b)
|
|
|
|
) engine=merge union=(t2,t3);
|
|
|
|
create table t2 (
|
2005-09-27 15:26:16 +02:00
|
|
|
a double(14,4),
|
2005-09-23 10:15:11 +02:00
|
|
|
b varchar(10),
|
|
|
|
index (a,b)
|
|
|
|
) engine=myisam;
|
|
|
|
create table t3 (
|
2005-09-27 15:26:16 +02:00
|
|
|
a double(14,4),
|
2005-09-23 10:15:11 +02:00
|
|
|
b varchar(10),
|
|
|
|
index (a,b)
|
|
|
|
) engine=myisam;
|
|
|
|
insert into t2 values ( null, '');
|
2005-09-29 13:37:30 +02:00
|
|
|
insert into t2 values ( 9999999999.999, '');
|
2005-09-23 10:15:11 +02:00
|
|
|
insert into t3 select * from t2;
|
|
|
|
select min(a), max(a) from t1;
|
|
|
|
min(a) max(a)
|
2005-09-29 13:37:30 +02:00
|
|
|
9999999999.9990 9999999999.9990
|
2005-09-23 10:15:11 +02:00
|
|
|
flush tables;
|
|
|
|
select min(a), max(a) from t1;
|
|
|
|
min(a) max(a)
|
2005-09-29 13:37:30 +02:00
|
|
|
9999999999.9990 9999999999.9990
|
2005-09-23 10:15:11 +02:00
|
|
|
drop table t1, t2, t3;
|
2004-11-29 04:51:30 +01:00
|
|
|
create table t1 (a int,b int,c int, index (a,b,c));
|
|
|
|
create table t2 (a int,b int,c int, index (a,b,c));
|
|
|
|
create table t3 (a int,b int,c int, index (a,b,c))
|
|
|
|
engine=merge union=(t1 ,t2);
|
|
|
|
insert into t1 (a,b,c) values (1,1,0),(1,2,0);
|
|
|
|
insert into t2 (a,b,c) values (1,1,1),(1,2,1);
|
|
|
|
explain select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
|
|
|
select a,b,c from t3 force index (a) where a=1 order by a,b,c;
|
|
|
|
a b c
|
|
|
|
1 1 0
|
|
|
|
1 1 1
|
|
|
|
1 2 0
|
|
|
|
1 2 1
|
|
|
|
explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t3 ref a a 5 const 2 Using where; Using index
|
|
|
|
select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc;
|
|
|
|
a b c
|
|
|
|
1 2 1
|
|
|
|
1 2 0
|
|
|
|
1 1 1
|
|
|
|
1 1 0
|
2004-12-27 13:05:35 +01:00
|
|
|
show index from t3;
|
|
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
|
|
|
t3 1 a 1 a A NULL NULL NULL YES BTREE
|
|
|
|
t3 1 a 2 b A NULL NULL NULL YES BTREE
|
|
|
|
t3 1 a 3 c A NULL NULL NULL YES BTREE
|
2004-11-29 04:51:30 +01:00
|
|
|
drop table t1, t2, t3;
|
2005-05-18 19:40:39 +02:00
|
|
|
CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) )
|
|
|
|
ENGINE=MyISAM;
|
|
|
|
CREATE TABLE t2 ( a INT AUTO_INCREMENT, b VARCHAR(10), INDEX (a), INDEX (b) )
|
|
|
|
ENGINE=MERGE UNION (t1) INSERT_METHOD=FIRST;
|
|
|
|
INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=2;
|
|
|
|
INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3;
|
|
|
|
SELECT b FROM t2;
|
|
|
|
b
|
|
|
|
3
|
|
|
|
DROP TABLE t1, t2;
|
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.
mysql-test/r/create.result:
BUG#5390 - problems with merge tables
Removed a duplicate test.
mysql-test/r/merge.result:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT
Added test results.
mysql-test/t/create.test:
BUG#5390 - problems with merge tables
Removed a duplicate test.
mysql-test/t/merge.test:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT
Added tests.
sql/lock.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added a new function to find a duplicate lock in a list of tables.
sql/mysql_priv.h:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
Added a declaration for the new function.
sql/sql_base.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
Added a call to the new mysql_lock_have_duplicate(),
which needs the thread handle, to unique_table().
sql/sql_delete.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_insert.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_load.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_parse.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_update.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
Replaced a call to find_table_in_local_list() by
the newly extended unique_table().
2005-12-20 16:35:05 +01:00
|
|
|
create table t1(a int);
|
|
|
|
create table t2(a int);
|
|
|
|
insert into t1 values (1);
|
|
|
|
insert into t2 values (2);
|
|
|
|
create table t3 (a int) engine=merge union=(t1, t2) insert_method=first;
|
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
insert t2 select * from t2;
|
|
|
|
select * from t2;
|
|
|
|
a
|
|
|
|
2
|
|
|
|
2
|
|
|
|
insert t3 select * from t1;
|
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
insert t1 select * from t3;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
select * from t2;
|
|
|
|
a
|
|
|
|
2
|
|
|
|
2
|
|
|
|
select * from t3;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
2
|
|
|
|
2
|
|
|
|
2
|
|
|
|
2
|
|
|
|
check table t1, t2;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 check status OK
|
|
|
|
test.t2 check status OK
|
|
|
|
drop table t1, t2, t3;
|
2006-09-28 19:10:06 +02:00
|
|
|
CREATE TABLE t1(a INT);
|
|
|
|
INSERT INTO t1 VALUES(2),(1);
|
|
|
|
CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM t2 WHERE a=2;
|
2007-01-31 13:15:20 +01:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2006-09-28 19:10:06 +02:00
|
|
|
DROP TABLE t1, t2;
|
2006-09-27 15:33:31 +02:00
|
|
|
CREATE TABLE t1(a INT) ENGINE=MEMORY;
|
|
|
|
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM t2;
|
2006-10-06 07:54:47 +02:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2006-09-27 15:33:31 +02:00
|
|
|
DROP TABLE t1, t2;
|
|
|
|
CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3);
|
|
|
|
SELECT * FROM t2;
|
2006-10-06 07:54:47 +02:00
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
2006-09-27 15:33:31 +02:00
|
|
|
DROP TABLE t2;
|
2007-01-31 13:15:20 +01:00
|
|
|
CREATE TABLE t1(a INT, b TEXT);
|
|
|
|
CREATE TABLE tm1(a TEXT, b INT) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
DROP TABLE t1, tm1;
|
|
|
|
CREATE TABLE t1(a SMALLINT, b SMALLINT);
|
|
|
|
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
DROP TABLE t1, tm1;
|
|
|
|
CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(a, b));
|
|
|
|
CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
DROP TABLE t1, tm1;
|
|
|
|
CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(b));
|
|
|
|
CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
DROP TABLE t1, tm1;
|
BUG#26881 - Large MERGE tables report incorrect specification when no
differences in tables
Certain merge tables were wrongly reported as having incorrect definition:
- Some fields that are 1 byte long (e.g. TINYINT, CHAR(1)), might
be internally casted (in certain cases) to a different type on a
storage engine layer. (affects 4.1 and up)
- If tables in a merge (and a MERGE table itself) had short VARCHAR column (less
than 4 bytes) and at least one (but not all) tables were ALTER'ed (even to an
identical table: ALTER TABLE xxx ENGINE=yyy), table definitions went ouf of
sync. (affects 4.1 only)
This is fixed by relaxing a check for underlying conformance and setting
field type to FIELD_TYPE_STRING in case varchar is shorter than 4
when a table is created.
myisam/mi_create.c:
Added a comment.
mysql-test/r/merge.result:
A test case for bug#26881.
mysql-test/t/merge.test:
A test case for bug#26881.
sql/ha_myisam.cc:
Relaxed some checks performed by check_definition():
As comparing of fulltext keys (and key segments) is not yet implemented,
only return an error in case one of keys is fulltext and other is not.
Otherwise, if both keys are fulltext, accept them as is.
As comparing of spatial keys (and key segments) is not yet implemented,
only return an error in case one of keys is spatial and other is not.
Otherwise, if both keys are spatial, accept them as is.
A workaround to handle situation when field is casted from FIELD_SKIP_ZERO
to FIELD_NORMAL. This could happen only in case field length is 1 and row
format is fixed.
sql/sql_parse.cc:
When a table that has varchar field shorter than 4 is created, field type is
set to FIELD_TYPE_VAR_STRING. Later, when a table is modified using alter
table, field type is changed to FIELD_TYPE_STRING (see Field_string::type).
That means HA_OPTION_PACK_RECORD flag might be lost and thus null_bit might
be shifted by alter table, in other words alter table doesn't create 100%
equal table definition.
This is usually not a problem, since when a table is created/altered,
definition on a storage engine layer is based on one that is passed from
sql layer. But it is a problem for merge engine - null_bit is shifted when
a table (merge or underlying) is altered.
Set field type to FIELD_TYPE_STRING in case FIELD_TYPE_VAR_STRING is shorter
than 4 when a table is created as it is done in Field::type.
2007-03-13 15:02:06 +01:00
|
|
|
CREATE TABLE t1(c1 VARCHAR(1));
|
|
|
|
CREATE TABLE m1 LIKE t1;
|
|
|
|
ALTER TABLE m1 ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM m1;
|
|
|
|
c1
|
|
|
|
DROP TABLE t1, m1;
|
|
|
|
CREATE TABLE t1(c1 VARCHAR(4), c2 TINYINT, c3 TINYINT, c4 TINYINT,
|
|
|
|
c5 TINYINT, c6 TINYINT, c7 TINYINT, c8 TINYINT, c9 TINYINT);
|
|
|
|
CREATE TABLE m1 LIKE t1;
|
|
|
|
ALTER TABLE m1 ENGINE=MERGE UNION=(t1);
|
|
|
|
SELECT * FROM m1;
|
|
|
|
c1 c2 c3 c4 c5 c6 c7 c8 c9
|
|
|
|
DROP TABLE t1, m1;
|
2007-04-10 22:40:35 +02:00
|
|
|
CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_german2_ci,
|
|
|
|
b INT, INDEX(a,b));
|
|
|
|
CREATE TABLE t2 LIKE t1;
|
|
|
|
CREATE TABLE t3 LIKE t1;
|
|
|
|
ALTER TABLE t3 ENGINE=MERGE UNION=(t1,t2);
|
|
|
|
INSERT INTO t1 VALUES ('ss',1);
|
|
|
|
INSERT INTO t2 VALUES ('ss',2),(0xDF,2);
|
|
|
|
SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2;
|
|
|
|
COUNT(*)
|
|
|
|
2
|
|
|
|
DROP TABLE t1,t2,t3;
|
2006-05-31 02:10:53 +02:00
|
|
|
create table t1 (b bit(1));
|
|
|
|
create table t2 (b bit(1));
|
|
|
|
create table tm (b bit(1)) engine = merge union = (t1,t2);
|
|
|
|
select * from tm;
|
|
|
|
b
|
|
|
|
drop table tm, t1, t2;
|
2006-07-12 02:28:50 +02:00
|
|
|
create table t1 (a int) insert_method = last engine = merge;
|
|
|
|
insert into t1 values (1);
|
|
|
|
ERROR HY000: Table 't1' is read only
|
|
|
|
create table t2 (a int) engine = myisam;
|
|
|
|
alter table t1 union (t2);
|
|
|
|
insert into t1 values (1);
|
|
|
|
alter table t1 insert_method = no;
|
|
|
|
insert into t1 values (1);
|
|
|
|
ERROR HY000: Table 't1' is read only
|
|
|
|
drop table t2;
|
|
|
|
drop table t1;
|
BUG#26976 - Missing table in merge not noted in related error msg +
SHOW CREATE TABLE fails
Underlying table names, that merge engine fails to open were not
reported.
With this fix CHECK TABLE issued against merge table reports all
underlying table names that it fails to open. Other statements
are unaffected, that is underlying table names are not included
into error message.
This fix doesn't solve SHOW CREATE TABLE issue.
myisammrg/myrg_def.h:
Added myrg_print_wrong_table declaration.
myisammrg/myrg_open.c:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
mysql-test/r/backup.result:
Updated test result.
mysql-test/r/key_cache.result:
Updated test result - removed duplicate error.
mysql-test/r/lock.result:
Updated test result - added summary row.
mysql-test/r/merge.result:
A test case for BUG#26976.
mysql-test/r/preload.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/ps.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/repair.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/rpl_failed_optimize.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/sp.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/view.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/t/merge.test:
A test case for BUG#26976.
sql/ha_myisam.cc:
Do not report same error twice.
sql/ha_myisammrg.cc:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
Added dummy ha_myisammrg::check to not confuse users with
"not implemented" error in case all underlying tables are
fine.
sql/ha_myisammrg.h:
Added ha_myisammrg::check declaration.
sql/share/errmsg.txt:
Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead
of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is
passed to merge engine handler open function.
sql/sql_error.cc:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_error.h:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_table.cc:
Reorder mysql_admin_table arguments to meet it's definition.
Report errors that are pending in thd->warn_list as results of
admin function.
2007-06-06 01:42:41 +02:00
|
|
|
CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
CHECK TABLE tm1;
|
|
|
|
Table Op Msg_type Msg_text
|
2007-06-14 13:18:01 +02:00
|
|
|
test.tm1 check Error Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
|
BUG#26976 - Missing table in merge not noted in related error msg +
SHOW CREATE TABLE fails
Underlying table names, that merge engine fails to open were not
reported.
With this fix CHECK TABLE issued against merge table reports all
underlying table names that it fails to open. Other statements
are unaffected, that is underlying table names are not included
into error message.
This fix doesn't solve SHOW CREATE TABLE issue.
myisammrg/myrg_def.h:
Added myrg_print_wrong_table declaration.
myisammrg/myrg_open.c:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
mysql-test/r/backup.result:
Updated test result.
mysql-test/r/key_cache.result:
Updated test result - removed duplicate error.
mysql-test/r/lock.result:
Updated test result - added summary row.
mysql-test/r/merge.result:
A test case for BUG#26976.
mysql-test/r/preload.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/ps.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/repair.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/rpl_failed_optimize.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/sp.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/view.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/t/merge.test:
A test case for BUG#26976.
sql/ha_myisam.cc:
Do not report same error twice.
sql/ha_myisammrg.cc:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
Added dummy ha_myisammrg::check to not confuse users with
"not implemented" error in case all underlying tables are
fine.
sql/ha_myisammrg.h:
Added ha_myisammrg::check declaration.
sql/share/errmsg.txt:
Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead
of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is
passed to merge engine handler open function.
sql/sql_error.cc:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_error.h:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_table.cc:
Reorder mysql_admin_table arguments to meet it's definition.
Report errors that are pending in thd->warn_list as results of
admin function.
2007-06-06 01:42:41 +02:00
|
|
|
test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
test.tm1 check error Corrupt
|
|
|
|
CREATE TABLE t1(a INT);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
CHECK TABLE tm1;
|
|
|
|
Table Op Msg_type Msg_text
|
2007-06-14 13:18:01 +02:00
|
|
|
test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
|
BUG#26976 - Missing table in merge not noted in related error msg +
SHOW CREATE TABLE fails
Underlying table names, that merge engine fails to open were not
reported.
With this fix CHECK TABLE issued against merge table reports all
underlying table names that it fails to open. Other statements
are unaffected, that is underlying table names are not included
into error message.
This fix doesn't solve SHOW CREATE TABLE issue.
myisammrg/myrg_def.h:
Added myrg_print_wrong_table declaration.
myisammrg/myrg_open.c:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
mysql-test/r/backup.result:
Updated test result.
mysql-test/r/key_cache.result:
Updated test result - removed duplicate error.
mysql-test/r/lock.result:
Updated test result - added summary row.
mysql-test/r/merge.result:
A test case for BUG#26976.
mysql-test/r/preload.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/ps.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/repair.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/rpl_failed_optimize.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/sp.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/view.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/t/merge.test:
A test case for BUG#26976.
sql/ha_myisam.cc:
Do not report same error twice.
sql/ha_myisammrg.cc:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
Added dummy ha_myisammrg::check to not confuse users with
"not implemented" error in case all underlying tables are
fine.
sql/ha_myisammrg.h:
Added ha_myisammrg::check declaration.
sql/share/errmsg.txt:
Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead
of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is
passed to merge engine handler open function.
sql/sql_error.cc:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_error.h:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_table.cc:
Reorder mysql_admin_table arguments to meet it's definition.
Report errors that are pending in thd->warn_list as results of
admin function.
2007-06-06 01:42:41 +02:00
|
|
|
test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
test.tm1 check error Corrupt
|
|
|
|
CREATE TABLE t2(a BLOB);
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
CHECK TABLE tm1;
|
|
|
|
Table Op Msg_type Msg_text
|
2007-06-14 13:18:01 +02:00
|
|
|
test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist
|
BUG#26976 - Missing table in merge not noted in related error msg +
SHOW CREATE TABLE fails
Underlying table names, that merge engine fails to open were not
reported.
With this fix CHECK TABLE issued against merge table reports all
underlying table names that it fails to open. Other statements
are unaffected, that is underlying table names are not included
into error message.
This fix doesn't solve SHOW CREATE TABLE issue.
myisammrg/myrg_def.h:
Added myrg_print_wrong_table declaration.
myisammrg/myrg_open.c:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
mysql-test/r/backup.result:
Updated test result.
mysql-test/r/key_cache.result:
Updated test result - removed duplicate error.
mysql-test/r/lock.result:
Updated test result - added summary row.
mysql-test/r/merge.result:
A test case for BUG#26976.
mysql-test/r/preload.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/ps.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/repair.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/rpl_failed_optimize.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/sp.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/r/view.result:
Updated test result - removed duplicate error, added summary row.
mysql-test/t/merge.test:
A test case for BUG#26976.
sql/ha_myisam.cc:
Do not report same error twice.
sql/ha_myisammrg.cc:
If HA_OPEN_FOR_REPAIR is passed to merge engine open function,
report names of tables that we fail to open.
Added dummy ha_myisammrg::check to not confuse users with
"not implemented" error in case all underlying tables are
fine.
sql/ha_myisammrg.h:
Added ha_myisammrg::check declaration.
sql/share/errmsg.txt:
Added ER_ADMIN_WRONG_MRG_TABLE errno. It is used instead
of ER_WRONG_MRG_TABLE in case HA_OPEN_FOR_REPAIR is
passed to merge engine handler open function.
sql/sql_error.cc:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_error.h:
warning_level_* are now public. It is required by mysql_admin_table to
report message level.
sql/sql_table.cc:
Reorder mysql_admin_table arguments to meet it's definition.
Report errors that are pending in thd->warn_list as results of
admin function.
2007-06-06 01:42:41 +02:00
|
|
|
test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
|
|
|
|
test.tm1 check error Corrupt
|
|
|
|
ALTER TABLE t2 MODIFY a INT;
|
|
|
|
SELECT * FROM tm1;
|
|
|
|
a
|
|
|
|
CHECK TABLE tm1;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.tm1 check status OK
|
|
|
|
DROP TABLE tm1, t1, t2;
|
2006-07-12 02:28:50 +02:00
|
|
|
End of 5.0 tests
|