2006-08-16 14:58:49 +02:00
|
|
|
SET SESSION STORAGE_ENGINE = InnoDB;
|
2006-06-04 20:05:22 +02:00
|
|
|
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
|
2006-05-06 11:15:00 +02:00
|
|
|
create table t1 (
|
|
|
|
c_id int(11) not null default '0',
|
|
|
|
org_id int(11) default null,
|
|
|
|
unique key contacts$c_id (c_id),
|
|
|
|
key contacts$org_id (org_id)
|
2006-08-16 14:58:49 +02:00
|
|
|
);
|
2006-08-16 19:29:49 +02:00
|
|
|
insert into t1 values
|
2006-05-06 11:15:00 +02:00
|
|
|
(2,null),(120,null),(141,null),(218,7), (128,1),
|
|
|
|
(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
|
|
|
|
(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
|
|
|
|
create table t2 (
|
|
|
|
slai_id int(11) not null default '0',
|
|
|
|
owner_tbl int(11) default null,
|
|
|
|
owner_id int(11) default null,
|
|
|
|
sla_id int(11) default null,
|
|
|
|
inc_web int(11) default null,
|
|
|
|
inc_email int(11) default null,
|
|
|
|
inc_chat int(11) default null,
|
|
|
|
inc_csr int(11) default null,
|
|
|
|
inc_total int(11) default null,
|
|
|
|
time_billed int(11) default null,
|
|
|
|
activedate timestamp null default null,
|
|
|
|
expiredate timestamp null default null,
|
|
|
|
state int(11) default null,
|
|
|
|
sla_set int(11) default null,
|
|
|
|
unique key t2$slai_id (slai_id),
|
|
|
|
key t2$owner_id (owner_id),
|
|
|
|
key t2$sla_id (sla_id)
|
2006-08-16 14:58:49 +02:00
|
|
|
);
|
2006-05-06 11:15:00 +02:00
|
|
|
insert into t2(slai_id, owner_tbl, owner_id, sla_id) values
|
|
|
|
(1,3,1,1), (3,3,10,2), (4,3,3,6), (5,3,2,5), (6,3,8,3), (7,3,9,7),
|
|
|
|
(8,3,6,8), (9,3,4,9), (10,3,5,10), (11,3,11,11), (12,3,7,12);
|
|
|
|
flush tables;
|
|
|
|
select si.slai_id
|
|
|
|
from t1 c join t2 si on
|
2006-08-16 19:29:49 +02:00
|
|
|
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
|
|
|
|
( si.owner_tbl = 2 and si.owner_id = c.c_id))
|
|
|
|
where
|
2006-05-06 11:15:00 +02:00
|
|
|
c.c_id = 218 and expiredate is null;
|
|
|
|
slai_id
|
|
|
|
12
|
|
|
|
select * from t1 where org_id is null;
|
|
|
|
c_id org_id
|
|
|
|
2 NULL
|
|
|
|
120 NULL
|
|
|
|
141 NULL
|
|
|
|
select si.slai_id
|
|
|
|
from t1 c join t2 si on
|
2006-08-16 19:29:49 +02:00
|
|
|
((si.owner_tbl = 3 and si.owner_id = c.org_id) or
|
|
|
|
( si.owner_tbl = 2 and si.owner_id = c.c_id))
|
|
|
|
where
|
2006-05-06 11:15:00 +02:00
|
|
|
c.c_id = 218 and expiredate is null;
|
|
|
|
slai_id
|
|
|
|
12
|
|
|
|
drop table t1, t2;
|
2006-08-16 19:29:49 +02:00
|
|
|
CREATE TABLE t1 (a int, b int, KEY b (b));
|
|
|
|
CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b));
|
|
|
|
CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
|
|
|
|
UNIQUE KEY b (b,c), KEY a (a,b,c));
|
2006-07-12 09:57:38 +02:00
|
|
|
INSERT INTO t1 VALUES (1, 1);
|
|
|
|
INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
|
|
|
|
INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
|
|
|
|
INSERT INTO t2 SELECT a + 1, b FROM t2;
|
|
|
|
DELETE FROM t2 WHERE a = 1 AND b < 2;
|
|
|
|
INSERT INTO t3 VALUES (1,1,1),(2,1,2);
|
|
|
|
INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
|
|
|
|
INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
|
2006-08-16 19:29:49 +02:00
|
|
|
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
|
|
|
|
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
|
2006-07-12 09:57:38 +02:00
|
|
|
ORDER BY t1.b LIMIT 2;
|
|
|
|
b a
|
|
|
|
1 1
|
|
|
|
2 2
|
2006-08-16 19:29:49 +02:00
|
|
|
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
|
|
|
|
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
|
2006-07-12 09:57:38 +02:00
|
|
|
ORDER BY t1.b LIMIT 5;
|
|
|
|
b a
|
|
|
|
1 1
|
|
|
|
2 2
|
|
|
|
2 2
|
|
|
|
3 3
|
|
|
|
3 3
|
|
|
|
DROP TABLE t1, t2, t3;
|
2006-08-15 18:33:14 +02:00
|
|
|
CREATE TABLE `t1` (`id1` INT) ;
|
|
|
|
INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
|
|
|
|
CREATE TABLE `t2` (
|
|
|
|
`id1` INT,
|
|
|
|
`id2` INT NOT NULL,
|
|
|
|
`id3` INT,
|
|
|
|
`id4` INT NOT NULL,
|
|
|
|
UNIQUE (`id2`,`id4`),
|
|
|
|
KEY (`id1`)
|
2006-09-18 16:55:56 +02:00
|
|
|
);
|
|
|
|
INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
|
2006-08-15 18:33:14 +02:00
|
|
|
(1,1,1,0),
|
|
|
|
(1,1,2,1),
|
|
|
|
(5,1,2,2),
|
|
|
|
(6,1,2,3),
|
|
|
|
(1,2,2,2),
|
|
|
|
(1,2,1,1);
|
|
|
|
SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
|
|
|
|
id1
|
|
|
|
2
|
|
|
|
DROP TABLE t1, t2;
|
2006-10-11 10:44:03 +02:00
|
|
|
create table t1 (c1 int) engine=innodb;
|
|
|
|
handler t1 open;
|
|
|
|
handler t1 read first;
|
|
|
|
c1
|
2006-10-30 13:35:57 +01:00
|
|
|
Before and after comparison
|
|
|
|
0
|
2006-10-11 10:44:03 +02:00
|
|
|
drop table t1;
|
2007-04-29 01:16:17 +02:00
|
|
|
CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
c1 cnt
|
|
|
|
1a 1
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
c1 cnt
|
|
|
|
1a 2
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
c1 cnt
|
|
|
|
1a 1
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
c1 cnt
|
|
|
|
1a 2
|
|
|
|
DROP TABLE t1;
|
|
|
|
CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
|
|
|
|
ENGINE=INNODB CHARACTER SET UTF8;
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1a');
|
|
|
|
SELECT * FROM t1;
|
|
|
|
c1 cnt
|
|
|
|
1a 1
|
|
|
|
INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
c1 cnt
|
|
|
|
1a 2
|
|
|
|
DROP TABLE t1;
|
2007-05-15 08:55:18 +02:00
|
|
|
CREATE TABLE t1 (
|
|
|
|
a1 decimal(10,0) DEFAULT NULL,
|
|
|
|
a2 blob,
|
|
|
|
a3 time DEFAULT NULL,
|
|
|
|
a4 blob,
|
|
|
|
a5 char(175) DEFAULT NULL,
|
|
|
|
a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
|
|
|
a7 tinyblob,
|
|
|
|
INDEX idx (a6,a7(239),a5)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
EXPLAIN SELECT a4 FROM t1 WHERE
|
|
|
|
a6=NULL AND
|
|
|
|
a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
|
|
|
EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE
|
|
|
|
t.a6=t.a6 AND t1.a6=NULL AND
|
|
|
|
t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS';
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
|
|
|
DROP TABLE t1;
|
2006-10-11 10:44:03 +02:00
|
|
|
End of 4.1 tests
|
2006-08-16 14:58:49 +02:00
|
|
|
create table t1m (a int) engine = MEMORY;
|
|
|
|
create table t1i (a int);
|
|
|
|
create table t2m (a int) engine = MEMORY;
|
|
|
|
create table t2i (a int);
|
2006-05-22 15:10:53 +02:00
|
|
|
insert into t2m values (5);
|
|
|
|
insert into t2i values (5);
|
|
|
|
select min(a) from t1i;
|
|
|
|
min(a)
|
|
|
|
NULL
|
|
|
|
select min(7) from t1i;
|
|
|
|
min(7)
|
|
|
|
NULL
|
|
|
|
select min(7) from DUAL;
|
|
|
|
min(7)
|
2006-09-05 18:07:55 +02:00
|
|
|
7
|
2006-05-22 15:10:53 +02:00
|
|
|
explain select min(7) from t2i join t1i;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2007-05-29 14:58:18 +02:00
|
|
|
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
|
|
|
|
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer
|
2006-05-22 15:10:53 +02:00
|
|
|
select min(7) from t2i join t1i;
|
|
|
|
min(7)
|
|
|
|
NULL
|
|
|
|
select max(a) from t1i;
|
|
|
|
max(a)
|
|
|
|
NULL
|
|
|
|
select max(7) from t1i;
|
|
|
|
max(7)
|
|
|
|
NULL
|
|
|
|
select max(7) from DUAL;
|
|
|
|
max(7)
|
2006-09-05 18:07:55 +02:00
|
|
|
7
|
2006-05-22 15:10:53 +02:00
|
|
|
explain select max(7) from t2i join t1i;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
2007-05-29 14:58:18 +02:00
|
|
|
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
|
|
|
|
1 SIMPLE t1i ALL NULL NULL NULL NULL 1 Using join buffer
|
2006-05-22 15:10:53 +02:00
|
|
|
select max(7) from t2i join t1i;
|
|
|
|
max(7)
|
|
|
|
NULL
|
|
|
|
select 1, min(a) from t1i where a=99;
|
|
|
|
1 min(a)
|
|
|
|
1 NULL
|
|
|
|
select 1, min(a) from t1i where 1=99;
|
|
|
|
1 min(a)
|
|
|
|
1 NULL
|
|
|
|
select 1, min(1) from t1i where a=99;
|
|
|
|
1 min(1)
|
|
|
|
1 NULL
|
|
|
|
select 1, min(1) from t1i where 1=99;
|
|
|
|
1 min(1)
|
|
|
|
1 NULL
|
|
|
|
select 1, max(a) from t1i where a=99;
|
|
|
|
1 max(a)
|
|
|
|
1 NULL
|
|
|
|
select 1, max(a) from t1i where 1=99;
|
|
|
|
1 max(a)
|
|
|
|
1 NULL
|
|
|
|
select 1, max(1) from t1i where a=99;
|
|
|
|
1 max(1)
|
|
|
|
1 NULL
|
|
|
|
select 1, max(1) from t1i where 1=99;
|
|
|
|
1 max(1)
|
|
|
|
1 NULL
|
|
|
|
explain select count(*), min(7), max(7) from t1m, t1i;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
|
|
|
|
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
|
|
|
|
select count(*), min(7), max(7) from t1m, t1i;
|
|
|
|
count(*) min(7) max(7)
|
|
|
|
0 NULL NULL
|
|
|
|
explain select count(*), min(7), max(7) from t1m, t2i;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1m system NULL NULL NULL NULL 0 const row not found
|
|
|
|
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
|
|
|
|
select count(*), min(7), max(7) from t1m, t2i;
|
|
|
|
count(*) min(7) max(7)
|
|
|
|
0 NULL NULL
|
|
|
|
explain select count(*), min(7), max(7) from t2m, t1i;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t2m system NULL NULL NULL NULL 1
|
|
|
|
1 SIMPLE t1i ALL NULL NULL NULL NULL 1
|
|
|
|
select count(*), min(7), max(7) from t2m, t1i;
|
|
|
|
count(*) min(7) max(7)
|
|
|
|
0 NULL NULL
|
|
|
|
drop table t1m, t1i, t2m, t2i;
|
2006-05-23 15:43:01 +02:00
|
|
|
create table t1 (
|
|
|
|
a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
2006-08-16 14:58:49 +02:00
|
|
|
) ENGINE = MEMORY;
|
2006-05-23 15:43:01 +02:00
|
|
|
insert into t1 (a1, a2, b, c, d) values
|
|
|
|
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
|
|
|
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
|
|
|
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
|
|
|
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
|
|
|
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
|
|
|
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
|
|
|
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
|
|
|
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
|
|
|
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
|
|
|
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
|
|
|
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
|
|
|
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
|
|
|
|
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
|
|
|
|
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
|
|
|
|
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
|
|
|
|
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4'),
|
|
|
|
('a','a','a','a111','xy1'),('a','a','a','b111','xy2'),('a','a','a','c111','xy3'),('a','a','a','d111','xy4'),
|
|
|
|
('a','a','b','e112','xy1'),('a','a','b','f112','xy2'),('a','a','b','g112','xy3'),('a','a','b','h112','xy4'),
|
|
|
|
('a','b','a','i121','xy1'),('a','b','a','j121','xy2'),('a','b','a','k121','xy3'),('a','b','a','l121','xy4'),
|
|
|
|
('a','b','b','m122','xy1'),('a','b','b','n122','xy2'),('a','b','b','o122','xy3'),('a','b','b','p122','xy4'),
|
|
|
|
('b','a','a','a211','xy1'),('b','a','a','b211','xy2'),('b','a','a','c211','xy3'),('b','a','a','d211','xy4'),
|
|
|
|
('b','a','b','e212','xy1'),('b','a','b','f212','xy2'),('b','a','b','g212','xy3'),('b','a','b','h212','xy4'),
|
|
|
|
('b','b','a','i221','xy1'),('b','b','a','j221','xy2'),('b','b','a','k221','xy3'),('b','b','a','l221','xy4'),
|
|
|
|
('b','b','b','m222','xy1'),('b','b','b','n222','xy2'),('b','b','b','o222','xy3'),('b','b','b','p222','xy4'),
|
|
|
|
('c','a','a','a311','xy1'),('c','a','a','b311','xy2'),('c','a','a','c311','xy3'),('c','a','a','d311','xy4'),
|
|
|
|
('c','a','b','e312','xy1'),('c','a','b','f312','xy2'),('c','a','b','g312','xy3'),('c','a','b','h312','xy4'),
|
|
|
|
('c','b','a','i321','xy1'),('c','b','a','j321','xy2'),('c','b','a','k321','xy3'),('c','b','a','l321','xy4'),
|
|
|
|
('c','b','b','m322','xy1'),('c','b','b','n322','xy2'),('c','b','b','o322','xy3'),('c','b','b','p322','xy4'),
|
|
|
|
('d','a','a','a411','xy1'),('d','a','a','b411','xy2'),('d','a','a','c411','xy3'),('d','a','a','d411','xy4'),
|
|
|
|
('d','a','b','e412','xy1'),('d','a','b','f412','xy2'),('d','a','b','g412','xy3'),('d','a','b','h412','xy4'),
|
|
|
|
('d','b','a','i421','xy1'),('d','b','a','j421','xy2'),('d','b','a','k421','xy3'),('d','b','a','l421','xy4'),
|
|
|
|
('d','b','b','m422','xy1'),('d','b','b','n422','xy2'),('d','b','b','o422','xy3'),('d','b','b','p422','xy4');
|
|
|
|
create table t4 (
|
|
|
|
pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
|
2006-08-16 14:58:49 +02:00
|
|
|
);
|
2006-05-23 15:43:01 +02:00
|
|
|
insert into t4 (a1, a2, b, c, d, dummy) select * from t1;
|
|
|
|
create index idx12672_0 on t4 (a1);
|
|
|
|
create index idx12672_1 on t4 (a1,a2,b,c);
|
|
|
|
create index idx12672_2 on t4 (a1,a2,b);
|
2006-08-16 14:58:49 +02:00
|
|
|
analyze table t4;
|
2006-05-23 15:43:01 +02:00
|
|
|
Table Op Msg_type Msg_text
|
2006-08-16 14:58:49 +02:00
|
|
|
test.t4 analyze status OK
|
2006-05-23 15:43:01 +02:00
|
|
|
select distinct a1 from t4 where pk_col not in (1,2,3,4);
|
|
|
|
a1
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
|
|
|
drop table t1,t4;
|
2006-10-25 17:53:26 +02:00
|
|
|
DROP TABLE IF EXISTS t2, t1;
|
|
|
|
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY) ENGINE= InnoDB;
|
|
|
|
CREATE TABLE t2 (
|
|
|
|
i INT NOT NULL,
|
|
|
|
FOREIGN KEY (i) REFERENCES t1 (i) ON DELETE NO ACTION
|
|
|
|
) ENGINE= InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1);
|
|
|
|
INSERT INTO t2 VALUES (1);
|
|
|
|
DELETE IGNORE FROM t1 WHERE i = 1;
|
|
|
|
Warnings:
|
2006-10-25 18:12:23 +02:00
|
|
|
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
|
2006-10-25 17:53:26 +02:00
|
|
|
SELECT * FROM t1, t2;
|
|
|
|
i i
|
|
|
|
1 1
|
|
|
|
DROP TABLE t2, t1;
|
|
|
|
End of 4.1 tests.
|
2006-05-23 15:43:01 +02:00
|
|
|
create table t1 (
|
|
|
|
a varchar(30), b varchar(30), primary key(a), key(b)
|
2006-08-16 14:58:49 +02:00
|
|
|
);
|
2006-05-23 15:43:01 +02:00
|
|
|
select distinct a from t1;
|
|
|
|
a
|
|
|
|
drop table t1;
|
2006-08-16 14:58:49 +02:00
|
|
|
create table t1(a int, key(a));
|
2006-05-23 15:43:01 +02:00
|
|
|
insert into t1 values(1);
|
|
|
|
select a, count(a) from t1 group by a with rollup;
|
|
|
|
a count(a)
|
|
|
|
1 1
|
|
|
|
NULL 1
|
|
|
|
drop table t1;
|
2006-08-16 14:58:49 +02:00
|
|
|
create table t1 (f1 int, f2 char(1), primary key(f1,f2));
|
2006-05-23 15:43:01 +02:00
|
|
|
insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
|
|
|
|
alter table t1 drop primary key, add primary key (f2, f1);
|
|
|
|
explain select distinct f1 a, f1 b from t1;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 index NULL PRIMARY 5 NULL 4 Using index; Using temporary
|
|
|
|
explain select distinct f1, f2 from t1;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
|
|
|
|
drop table t1;
|
2006-08-21 12:20:03 +02:00
|
|
|
CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
|
2006-09-18 16:55:56 +02:00
|
|
|
INDEX (name));
|
|
|
|
CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11));
|
|
|
|
ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id);
|
2006-08-21 12:20:03 +02:00
|
|
|
INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
|
|
|
|
INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
|
|
|
|
EXPLAIN
|
2006-09-18 16:55:56 +02:00
|
|
|
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
|
2006-08-21 12:20:03 +02:00
|
|
|
WHERE t1.name LIKE 'A%';
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
|
|
|
|
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
|
|
|
|
EXPLAIN
|
2006-09-18 16:55:56 +02:00
|
|
|
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
|
2006-08-21 12:20:03 +02:00
|
|
|
WHERE t1.name LIKE 'A%' OR FALSE;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
|
|
|
|
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
|
|
|
|
DROP TABLE t1,t2;
|
2006-10-09 17:51:41 +02:00
|
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
|
|
|
|
INSERT INTO t1 VALUES ( 1 , 1 , 1);
|
|
|
|
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
|
|
|
|
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 index NULL b 5 NULL 128
|
|
|
|
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
|
|
|
|
DROP TABLE t1;
|
2007-02-11 08:55:56 +01:00
|
|
|
CREATE TABLE t1 (
|
|
|
|
id int NOT NULL,
|
|
|
|
name varchar(20) NOT NULL,
|
|
|
|
dept varchar(20) NOT NULL,
|
|
|
|
age tinyint(3) unsigned NOT NULL,
|
|
|
|
PRIMARY KEY (id),
|
|
|
|
INDEX (name,dept)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1(id, dept, age, name) VALUES
|
|
|
|
(3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'),
|
|
|
|
(3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'),
|
|
|
|
(4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'),
|
|
|
|
(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6');
|
|
|
|
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 range name name 44 NULL 2 Using where; Using index for group-by
|
|
|
|
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
name dept
|
|
|
|
rs5 cs10
|
|
|
|
rs5 cs9
|
|
|
|
DELETE FROM t1;
|
|
|
|
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 range name name 44 NULL 2 Using where; Using index for group-by
|
|
|
|
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
|
|
|
name dept
|
|
|
|
DROP TABLE t1;
|
2006-12-20 00:57:51 +01:00
|
|
|
show variables like 'innodb_rollback_on_timeout';
|
|
|
|
Variable_name Value
|
|
|
|
innodb_rollback_on_timeout OFF
|
|
|
|
create table t1 (a int unsigned not null primary key) engine = innodb;
|
|
|
|
insert into t1 values (1);
|
|
|
|
commit;
|
|
|
|
begin work;
|
|
|
|
insert into t1 values (2);
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
begin work;
|
|
|
|
insert into t1 values (5);
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
5
|
|
|
|
insert into t1 values (2);
|
|
|
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
5
|
|
|
|
commit;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
commit;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
5
|
|
|
|
drop table t1;
|
2007-04-19 22:38:12 +02:00
|
|
|
set @save_qcache_size=@@global.query_cache_size;
|
|
|
|
set @save_qcache_type=@@global.query_cache_type;
|
|
|
|
set global query_cache_size=10*1024*1024;
|
|
|
|
set global query_cache_type=1;
|
|
|
|
drop table if exists `test`;
|
|
|
|
Warnings:
|
|
|
|
Note 1051 Unknown table 'test'
|
|
|
|
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
|
|
|
|
`test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`))
|
|
|
|
ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
|
|
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
|
|
|
|
select * from test;
|
|
|
|
test1 test2
|
|
|
|
tes 5678
|
|
|
|
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234')
|
|
|
|
ON DUPLICATE KEY UPDATE `test2` = '1234';
|
|
|
|
select * from test;
|
|
|
|
test1 test2
|
|
|
|
tes 1234
|
|
|
|
flush tables;
|
|
|
|
select * from test;
|
|
|
|
test1 test2
|
|
|
|
tes 1234
|
2007-04-20 00:20:57 +02:00
|
|
|
drop table test;
|
2007-04-19 22:38:12 +02:00
|
|
|
set global query_cache_type=@save_qcache_type;
|
|
|
|
set global query_cache_size=@save_qcache_size;
|
2007-04-29 16:59:31 +02:00
|
|
|
show variables like 'innodb_rollback_on_timeout';
|
|
|
|
Variable_name Value
|
|
|
|
innodb_rollback_on_timeout OFF
|
|
|
|
create table t1 (a int unsigned not null primary key) engine = innodb;
|
|
|
|
insert into t1 values (1);
|
|
|
|
commit;
|
|
|
|
begin work;
|
|
|
|
insert into t1 values (2);
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
begin work;
|
|
|
|
insert into t1 values (5);
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
5
|
|
|
|
insert into t1 values (2);
|
|
|
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
5
|
|
|
|
commit;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
commit;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
5
|
|
|
|
drop table t1;
|
|
|
|
set @save_qcache_size=@@global.query_cache_size;
|
|
|
|
set @save_qcache_type=@@global.query_cache_type;
|
|
|
|
set global query_cache_size=10*1024*1024;
|
|
|
|
set global query_cache_type=1;
|
|
|
|
drop table if exists `test`;
|
|
|
|
Warnings:
|
|
|
|
Note 1051 Unknown table 'test'
|
|
|
|
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
|
|
|
|
`test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`))
|
|
|
|
ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
|
|
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
|
|
|
|
select * from test;
|
|
|
|
test1 test2
|
|
|
|
tes 5678
|
|
|
|
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234')
|
|
|
|
ON DUPLICATE KEY UPDATE `test2` = '1234';
|
|
|
|
select * from test;
|
|
|
|
test1 test2
|
|
|
|
tes 1234
|
|
|
|
flush tables;
|
|
|
|
select * from test;
|
|
|
|
test1 test2
|
|
|
|
tes 1234
|
|
|
|
drop table test;
|
|
|
|
set global query_cache_type=@save_qcache_type;
|
|
|
|
set global query_cache_size=@save_qcache_size;
|
|
|
|
End of 5.0 tests
|
2007-04-25 23:01:23 +02:00
|
|
|
create table t1(
|
|
|
|
id int auto_increment,
|
|
|
|
c char(1) not null,
|
|
|
|
counter int not null default 1,
|
|
|
|
primary key (id),
|
|
|
|
unique key (c)
|
|
|
|
) engine=innodb;
|
|
|
|
insert into t1 (id, c) values
|
|
|
|
(NULL, 'a'),
|
|
|
|
(NULL, 'a')
|
|
|
|
on duplicate key update id = values(id), counter = counter + 1;
|
|
|
|
select * from t1;
|
|
|
|
id c counter
|
|
|
|
2 a 2
|
|
|
|
insert into t1 (id, c) values
|
|
|
|
(NULL, 'b')
|
|
|
|
on duplicate key update id = values(id), counter = counter + 1;
|
|
|
|
select * from t1;
|
|
|
|
id c counter
|
|
|
|
2 a 2
|
|
|
|
3 b 1
|
|
|
|
truncate table t1;
|
|
|
|
insert into t1 (id, c) values (NULL, 'a');
|
|
|
|
select * from t1;
|
|
|
|
id c counter
|
|
|
|
1 a 1
|
|
|
|
insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b')
|
|
|
|
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
|
|
|
|
select * from t1;
|
|
|
|
id c counter
|
|
|
|
1 a 1
|
|
|
|
3 b 2
|
|
|
|
insert into t1 (id, c) values (NULL, 'a')
|
|
|
|
on duplicate key update id = values(id), c = values(c), counter = counter + 1;
|
|
|
|
select * from t1;
|
|
|
|
id c counter
|
|
|
|
3 b 2
|
|
|
|
4 a 2
|
|
|
|
drop table t1;
|
2007-05-10 09:06:24 +02:00
|
|
|
CREATE TABLE t1(
|
|
|
|
id int AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
stat_id int NOT NULL,
|
|
|
|
acct_id int DEFAULT NULL,
|
|
|
|
INDEX idx1 (stat_id, acct_id),
|
|
|
|
INDEX idx2 (acct_id)
|
|
|
|
) ENGINE=MyISAM;
|
|
|
|
CREATE TABLE t2(
|
|
|
|
id int AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
stat_id int NOT NULL,
|
|
|
|
acct_id int DEFAULT NULL,
|
|
|
|
INDEX idx1 (stat_id, acct_id),
|
|
|
|
INDEX idx2 (acct_id)
|
|
|
|
) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) VALUES
|
|
|
|
(1,759), (2,831), (3,785), (4,854), (1,921),
|
|
|
|
(1,553), (2,589), (3,743), (2,827), (2,545),
|
|
|
|
(4,779), (4,783), (1,597), (1,785), (4,832),
|
|
|
|
(1,741), (1,833), (3,788), (2,973), (1,907);
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
|
|
|
|
UPDATE t1 SET acct_id=785
|
|
|
|
WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id);
|
|
|
|
OPTIMIZE TABLE t1;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t1 optimize status OK
|
|
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
COUNT(*)
|
|
|
|
40960
|
|
|
|
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
|
|
|
|
COUNT(*)
|
|
|
|
8702
|
|
|
|
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
|
|
|
|
INSERT INTO t2 SELECT * FROM t1;
|
|
|
|
OPTIMIZE TABLE t2;
|
|
|
|
Table Op Msg_type Msg_text
|
|
|
|
test.t2 optimize status OK
|
|
|
|
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t2 range idx1,idx2 idx1 9 NULL 2 Using where; Using index
|
|
|
|
DROP TABLE t1,t2;
|
2007-06-01 19:53:50 +02:00
|
|
|
create table t1(a int) engine=innodb;
|
|
|
|
alter table t1 comment '123';
|
|
|
|
show create table t1;
|
|
|
|
Table Create Table
|
|
|
|
t1 CREATE TABLE `t1` (
|
2007-06-04 08:52:14 +02:00
|
|
|
`a` int(11) DEFAULT NULL
|
2007-06-01 19:53:50 +02:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='123'
|
|
|
|
drop table t1;
|
2007-06-07 09:08:44 +02:00
|
|
|
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
|
|
|
|
INSERT INTO t1 VALUES ('uk'),('bg');
|
|
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
uk
|
|
|
|
DELETE FROM t1 WHERE a = 'uk';
|
|
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
UPDATE t1 SET a = 'us' WHERE a = 'uk';
|
|
|
|
SELECT * FROM t1 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
|
|
|
|
INSERT INTO t2 VALUES ('uk'),('bg');
|
|
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
uk
|
|
|
|
DELETE FROM t2 WHERE a = 'uk';
|
|
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
INSERT INTO t2 VALUES ('uk');
|
|
|
|
UPDATE t2 SET a = 'us' WHERE a = 'uk';
|
|
|
|
SELECT * FROM t2 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
|
|
|
|
INSERT INTO t3 VALUES ('uk'),('bg');
|
|
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
uk
|
|
|
|
DELETE FROM t3 WHERE a = 'uk';
|
|
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
INSERT INTO t3 VALUES ('uk');
|
|
|
|
UPDATE t3 SET a = 'us' WHERE a = 'uk';
|
|
|
|
SELECT * FROM t3 WHERE a = 'uk';
|
|
|
|
a
|
|
|
|
DROP TABLE t1,t2,t3;
|
2007-06-25 09:44:52 +02:00
|
|
|
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
|
|
|
|
switch to connection c1
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
INSERT INTO t2 VALUES (1);
|
|
|
|
switch to connection c2
|
|
|
|
SET AUTOCOMMIT=0;
|
|
|
|
LOCK TABLES t1 READ, t2 READ;
|
|
|
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
|
|
switch to connection c1
|
|
|
|
COMMIT;
|
|
|
|
INSERT INTO t1 VALUES (1);
|
|
|
|
switch to connection default
|
|
|
|
SET AUTOCOMMIT=default;
|
|
|
|
DROP TABLE t1,t2;
|
2006-10-24 22:42:08 +02:00
|
|
|
End of 5.0 tests
|
This changeset is largely a handler cleanup changeset (WL#3281), but includes fixes and cleanups that was found necessary while testing the handler changes
Changes that requires code changes in other code of other storage engines.
(Note that all changes are very straightforward and one should find all issues
by compiling a --debug build and fixing all compiler errors and all
asserts in field.cc while running the test suite),
- New optional handler function introduced: reset()
This is called after every DML statement to make it easy for a handler to
statement specific cleanups.
(The only case it's not called is if force the file to be closed)
- handler::extra(HA_EXTRA_RESET) is removed. Code that was there before
should be moved to handler::reset()
- table->read_set contains a bitmap over all columns that are needed
in the query. read_row() and similar functions only needs to read these
columns
- table->write_set contains a bitmap over all columns that will be updated
in the query. write_row() and update_row() only needs to update these
columns.
The above bitmaps should now be up to date in all context
(including ALTER TABLE, filesort()).
The handler is informed of any changes to the bitmap after
fix_fields() by calling the virtual function
handler::column_bitmaps_signal(). If the handler does caching of
these bitmaps (instead of using table->read_set, table->write_set),
it should redo the caching in this code. as the signal() may be sent
several times, it's probably best to set a variable in the signal
and redo the caching on read_row() / write_row() if the variable was
set.
- Removed the read_set and write_set bitmap objects from the handler class
- Removed all column bit handling functions from the handler class.
(Now one instead uses the normal bitmap functions in my_bitmap.c instead
of handler dedicated bitmap functions)
- field->query_id is removed. One should instead instead check
table->read_set and table->write_set if a field is used in the query.
- handler::extra(HA_EXTRA_RETRIVE_ALL_COLS) and
handler::extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) are removed. One should now
instead use table->read_set to check for which columns to retrieve.
- If a handler needs to call Field->val() or Field->store() on columns
that are not used in the query, one should install a temporary
all-columns-used map while doing so. For this, we provide the following
functions:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
field->val();
dbug_tmp_restore_column_map(table->read_set, old_map);
and similar for the write map:
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
field->val();
dbug_tmp_restore_column_map(table->write_set, old_map);
If this is not done, you will sooner or later hit a DBUG_ASSERT
in the field store() / val() functions.
(For not DBUG binaries, the dbug_tmp_restore_column_map() and
dbug_tmp_restore_column_map() are inline dummy functions and should
be optimized away be the compiler).
- If one needs to temporary set the column map for all binaries (and not
just to avoid the DBUG_ASSERT() in the Field::store() / Field::val()
methods) one should use the functions tmp_use_all_columns() and
tmp_restore_column_map() instead of the above dbug_ variants.
- All 'status' fields in the handler base class (like records,
data_file_length etc) are now stored in a 'stats' struct. This makes
it easier to know what status variables are provided by the base
handler. This requires some trivial variable names in the extra()
function.
- New virtual function handler::records(). This is called to optimize
COUNT(*) if (handler::table_flags() & HA_HAS_RECORDS()) is true.
(stats.records is not supposed to be an exact value. It's only has to
be 'reasonable enough' for the optimizer to be able to choose a good
optimization path).
- Non virtual handler::init() function added for caching of virtual
constants from engine.
- Removed has_transactions() virtual method. Now one should instead return
HA_NO_TRANSACTIONS in table_flags() if the table handler DOES NOT support
transactions.
- The 'xxxx_create_handler()' function now has a MEM_ROOT_root argument
that is to be used with 'new handler_name()' to allocate the handler
in the right area. The xxxx_create_handler() function is also
responsible for any initialization of the object before returning.
For example, one should change:
static handler *myisam_create_handler(TABLE_SHARE *table)
{
return new ha_myisam(table);
}
->
static handler *myisam_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
{
return new (mem_root) ha_myisam(table);
}
- New optional virtual function: use_hidden_primary_key().
This is called in case of an update/delete when
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
but we don't have a primary key. This allows the handler to take precisions
in remembering any hidden primary key to able to update/delete any
found row. The default handler marks all columns to be read.
- handler::table_flags() now returns a ulonglong (to allow for more flags).
- New/changed table_flags()
- HA_HAS_RECORDS Set if ::records() is supported
- HA_NO_TRANSACTIONS Set if engine doesn't support transactions
- HA_PRIMARY_KEY_REQUIRED_FOR_DELETE
Set if we should mark all primary key columns for
read when reading rows as part of a DELETE
statement. If there is no primary key,
all columns are marked for read.
- HA_PARTIAL_COLUMN_READ Set if engine will not read all columns in some
cases (based on table->read_set)
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS
Renamed to HA_PRIMARY_KEY_REQUIRED_FOR_POSITION.
- HA_DUPP_POS Renamed to HA_DUPLICATE_POS
- HA_REQUIRES_KEY_COLUMNS_FOR_DELETE
Set this if we should mark ALL key columns for
read when when reading rows as part of a DELETE
statement. In case of an update we will mark
all keys for read for which key part changed
value.
- HA_STATS_RECORDS_IS_EXACT
Set this if stats.records is exact.
(This saves us some extra records() calls
when optimizing COUNT(*))
- Removed table_flags()
- HA_NOT_EXACT_COUNT Now one should instead use HA_HAS_RECORDS if
handler::records() gives an exact count() and
HA_STATS_RECORDS_IS_EXACT if stats.records is exact.
- HA_READ_RND_SAME Removed (no one supported this one)
- Removed not needed functions ha_retrieve_all_cols() and ha_retrieve_all_pk()
- Renamed handler::dupp_pos to handler::dup_pos
- Removed not used variable handler::sortkey
Upper level handler changes:
- ha_reset() now does some overall checks and calls ::reset()
- ha_table_flags() added. This is a cached version of table_flags(). The
cache is updated on engine creation time and updated on open.
MySQL level changes (not obvious from the above):
- DBUG_ASSERT() added to check that column usage matches what is set
in the column usage bit maps. (This found a LOT of bugs in current
column marking code).
- In 5.1 before, all used columns was marked in read_set and only updated
columns was marked in write_set. Now we only mark columns for which we
need a value in read_set.
- Column bitmaps are created in open_binary_frm() and open_table_from_share().
(Before this was in table.cc)
- handler::table_flags() calls are replaced with handler::ha_table_flags()
- For calling field->val() you must have the corresponding bit set in
table->read_set. For calling field->store() you must have the
corresponding bit set in table->write_set. (There are asserts in
all store()/val() functions to catch wrong usage)
- thd->set_query_id is renamed to thd->mark_used_columns and instead
of setting this to an integer value, this has now the values:
MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE
Changed also all variables named 'set_query_id' to mark_used_columns.
- In filesort() we now inform the handler of exactly which columns are needed
doing the sort and choosing the rows.
- The TABLE_SHARE object has a 'all_set' column bitmap one can use
when one needs a column bitmap with all columns set.
(This is used for table->use_all_columns() and other places)
- The TABLE object has 3 column bitmaps:
- def_read_set Default bitmap for columns to be read
- def_write_set Default bitmap for columns to be written
- tmp_set Can be used as a temporary bitmap when needed.
The table object has also two pointer to bitmaps read_set and write_set
that the handler should use to find out which columns are used in which way.
- count() optimization now calls handler::records() instead of using
handler->stats.records (if (table_flags() & HA_HAS_RECORDS) is true).
- Added extra argument to Item::walk() to indicate if we should also
traverse sub queries.
- Added TABLE parameter to cp_buffer_from_ref()
- Don't close tables created with CREATE ... SELECT but keep them in
the table cache. (Faster usage of newly created tables).
New interfaces:
- table->clear_column_bitmaps() to initialize the bitmaps for tables
at start of new statements.
- table->column_bitmaps_set() to set up new column bitmaps and signal
the handler about this.
- table->column_bitmaps_set_no_signal() for some few cases where we need
to setup new column bitmaps but don't signal the handler (as the handler
has already been signaled about these before). Used for the momement
only in opt_range.cc when doing ROR scans.
- table->use_all_columns() to install a bitmap where all columns are marked
as use in the read and the write set.
- table->default_column_bitmaps() to install the normal read and write
column bitmaps, but not signaling the handler about this.
This is mainly used when creating TABLE instances.
- table->mark_columns_needed_for_delete(),
table->mark_columns_needed_for_delete() and
table->mark_columns_needed_for_insert() to allow us to put additional
columns in column usage maps if handler so requires.
(The handler indicates what it neads in handler->table_flags())
- table->prepare_for_position() to allow us to tell handler that it
needs to read primary key parts to be able to store them in
future table->position() calls.
(This replaces the table->file->ha_retrieve_all_pk function)
- table->mark_auto_increment_column() to tell handler are going to update
columns part of any auto_increment key.
- table->mark_columns_used_by_index() to mark all columns that is part of
an index. It will also send extra(HA_EXTRA_KEYREAD) to handler to allow
it to quickly know that it only needs to read colums that are part
of the key. (The handler can also use the column map for detecting this,
but simpler/faster handler can just monitor the extra() call).
- table->mark_columns_used_by_index_no_reset() to in addition to other columns,
also mark all columns that is used by the given key.
- table->restore_column_maps_after_mark_index() to restore to default
column maps after a call to table->mark_columns_used_by_index().
- New item function register_field_in_read_map(), for marking used columns
in table->read_map. Used by filesort() to mark all used columns
- Maintain in TABLE->merge_keys set of all keys that are used in query.
(Simplices some optimization loops)
- Maintain Field->part_of_key_not_clustered which is like Field->part_of_key
but the field in the clustered key is not assumed to be part of all index.
(used in opt_range.cc for faster loops)
- dbug_tmp_use_all_columns(), dbug_tmp_restore_column_map()
tmp_use_all_columns() and tmp_restore_column_map() functions to temporally
mark all columns as usable. The 'dbug_' version is primarily intended
inside a handler when it wants to just call Field:store() & Field::val()
functions, but don't need the column maps set for any other usage.
(ie:: bitmap_is_set() is never called)
- We can't use compare_records() to skip updates for handlers that returns
a partial column set and the read_set doesn't cover all columns in the
write set. The reason for this is that if we have a column marked only for
write we can't in the MySQL level know if the value changed or not.
The reason this worked before was that MySQL marked all to be written
columns as also to be read. The new 'optimal' bitmaps exposed this 'hidden
bug'.
- open_table_from_share() does not anymore setup temporary MEM_ROOT
object as a thread specific variable for the handler. Instead we
send the to-be-used MEMROOT to get_new_handler().
(Simpler, faster code)
Bugs fixed:
- Column marking was not done correctly in a lot of cases.
(ALTER TABLE, when using triggers, auto_increment fields etc)
(Could potentially result in wrong values inserted in table handlers
relying on that the old column maps or field->set_query_id was correct)
Especially when it comes to triggers, there may be cases where the
old code would cause lost/wrong values for NDB and/or InnoDB tables.
- Split thd->options flag OPTION_STATUS_NO_TRANS_UPDATE to two flags:
OPTION_STATUS_NO_TRANS_UPDATE and OPTION_KEEP_LOG.
This allowed me to remove some wrong warnings about:
"Some non-transactional changed tables couldn't be rolled back"
- Fixed handling of INSERT .. SELECT and CREATE ... SELECT that wrongly reset
(thd->options & OPTION_STATUS_NO_TRANS_UPDATE) which caused us to loose
some warnings about
"Some non-transactional changed tables couldn't be rolled back")
- Fixed use of uninitialized memory in ha_ndbcluster.cc::delete_table()
which could cause delete_table to report random failures.
- Fixed core dumps for some tests when running with --debug
- Added missing FN_LIBCHAR in mysql_rm_tmp_tables()
(This has probably caused us to not properly remove temporary files after
crash)
- slow_logs was not properly initialized, which could maybe cause
extra/lost entries in slow log.
- If we get an duplicate row on insert, change column map to read and
write all columns while retrying the operation. This is required by
the definition of REPLACE and also ensures that fields that are only
part of UPDATE are properly handled. This fixed a bug in NDB and
REPLACE where REPLACE wrongly copied some column values from the replaced
row.
- For table handler that doesn't support NULL in keys, we would give an error
when creating a primary key with NULL fields, even after the fields has been
automaticly converted to NOT NULL.
- Creating a primary key on a SPATIAL key, would fail if field was not
declared as NOT NULL.
Cleanups:
- Removed not used condition argument to setup_tables
- Removed not needed item function reset_query_id_processor().
- Field->add_index is removed. Now this is instead maintained in
(field->flags & FIELD_IN_ADD_INDEX)
- Field->fieldnr is removed (use field->field_index instead)
- New argument to filesort() to indicate that it should return a set of
row pointers (not used columns). This allowed me to remove some references
to sql_command in filesort and should also enable us to return column
results in some cases where we couldn't before.
- Changed column bitmap handling in opt_range.cc to be aligned with TABLE
bitmap, which allowed me to use bitmap functions instead of looping over
all fields to create some needed bitmaps. (Faster and smaller code)
- Broke up found too long lines
- Moved some variable declaration at start of function for better code
readability.
- Removed some not used arguments from functions.
(setup_fields(), mysql_prepare_insert_check_table())
- setup_fields() now takes an enum instead of an int for marking columns
usage.
- For internal temporary tables, use handler::write_row(),
handler::delete_row() and handler::update_row() instead of
handler::ha_xxxx() for faster execution.
- Changed some constants to enum's and define's.
- Using separate column read and write sets allows for easier checking
of timestamp field was set by statement.
- Remove calls to free_io_cache() as this is now done automaticly in ha_reset()
- Don't build table->normalized_path as this is now identical to table->path
(after bar's fixes to convert filenames)
- Fixed some missed DBUG_PRINT(.."%lx") to use "0x%lx" to make it easier to
do comparision with the 'convert-dbug-for-diff' tool.
Things left to do in 5.1:
- We wrongly log failed CREATE TABLE ... SELECT in some cases when using
row based logging (as shown by testcase binlog_row_mix_innodb_myisam.result)
Mats has promised to look into this.
- Test that my fix for CREATE TABLE ... SELECT is indeed correct.
(I added several test cases for this, but in this case it's better that
someone else also tests this throughly).
Lars has promosed to do this.
2006-06-04 17:52:22 +02:00
|
|
|
CREATE TABLE t1 (a int, b int);
|
|
|
|
insert into t1 values (1,1),(1,2);
|
|
|
|
CREATE TABLE t2 (primary key (a)) select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
drop table if exists t2;
|
|
|
|
Warnings:
|
|
|
|
Note 1051 Unknown table 't2'
|
|
|
|
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
drop table if exists t2;
|
|
|
|
Warnings:
|
|
|
|
Note 1051 Unknown table 't2'
|
|
|
|
CREATE TABLE t2 (a int, b int, primary key (a));
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 values(100,100);
|
|
|
|
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
100 100
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
100 100
|
|
|
|
TRUNCATE table t2;
|
|
|
|
INSERT INTO t2 select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
drop table t2;
|
|
|
|
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 values(100,100);
|
|
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
100 100
|
|
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t2 values(101,101);
|
|
|
|
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
100 100
|
|
|
|
101 101
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
100 100
|
|
|
|
TRUNCATE table t2;
|
|
|
|
INSERT INTO t2 select * from t1;
|
|
|
|
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
|
|
|
|
SELECT * from t2;
|
|
|
|
a b
|
|
|
|
drop table t1,t2;
|
2006-08-16 19:29:49 +02:00
|
|
|
create table t1(f1 varchar(800) binary not null, key(f1))
|
2006-05-18 12:55:34 +02:00
|
|
|
character set utf8 collate utf8_general_ci;
|
|
|
|
Warnings:
|
|
|
|
Warning 1071 Specified key was too long; max key length is 765 bytes
|
|
|
|
insert into t1 values('aaa');
|
|
|
|
drop table t1;
|
2006-10-09 17:51:41 +02:00
|
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c FLOAT, KEY b(b)) ENGINE = INNODB;
|
|
|
|
INSERT INTO t1 VALUES ( 1 , 1 , 1);
|
|
|
|
INSERT INTO t1 SELECT a + 1 , MOD(a + 1 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 2 , MOD(a + 2 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 4 , MOD(a + 4 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 8 , MOD(a + 8 , 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 16, MOD(a + 16, 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 32, MOD(a + 32, 20), 1 FROM t1;
|
|
|
|
INSERT INTO t1 SELECT a + 64, MOD(a + 64, 20), 1 FROM t1;
|
|
|
|
EXPLAIN SELECT b, SUM(c) FROM t1 GROUP BY b;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 index NULL b 5 NULL 128
|
|
|
|
EXPLAIN SELECT SQL_BIG_RESULT b, SUM(c) FROM t1 GROUP BY b;
|
|
|
|
id select_type table type possible_keys key key_len ref rows Extra
|
|
|
|
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
|
|
|
|
DROP TABLE t1;
|
2006-12-20 00:57:51 +01:00
|
|
|
show variables like 'innodb_rollback_on_timeout';
|
|
|
|
Variable_name Value
|
|
|
|
innodb_rollback_on_timeout OFF
|
|
|
|
create table t1 (a int unsigned not null primary key) engine = innodb;
|
|
|
|
insert into t1 values (1);
|
|
|
|
commit;
|
|
|
|
begin work;
|
|
|
|
insert into t1 values (2);
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
begin work;
|
|
|
|
insert into t1 values (5);
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
5
|
|
|
|
insert into t1 values (2);
|
|
|
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
5
|
|
|
|
commit;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
commit;
|
|
|
|
select * from t1;
|
|
|
|
a
|
|
|
|
1
|
|
|
|
2
|
|
|
|
5
|
|
|
|
drop table t1;
|
2006-10-24 22:42:08 +02:00
|
|
|
End of 5.0 tests
|
2006-09-01 16:51:37 +02:00
|
|
|
CREATE TABLE `t2` (
|
|
|
|
`k` int(11) NOT NULL auto_increment,
|
|
|
|
`a` int(11) default NULL,
|
|
|
|
`c` int(11) default NULL,
|
|
|
|
PRIMARY KEY (`k`),
|
|
|
|
UNIQUE KEY `idx_1` (`a`)
|
2006-09-18 16:55:56 +02:00
|
|
|
);
|
2006-09-01 16:51:37 +02:00
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
insert into t2 ( a ) values ( 7 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
select last_insert_id();
|
|
|
|
last_insert_id()
|
|
|
|
2
|
|
|
|
select * from t2;
|
|
|
|
k a c
|
|
|
|
1 6 NULL
|
|
|
|
2 7 NULL
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
select last_insert_id();
|
|
|
|
last_insert_id()
|
2006-09-06 12:50:42 +02:00
|
|
|
2
|
|
|
|
select last_insert_id(0);
|
|
|
|
last_insert_id(0)
|
|
|
|
0
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1;
|
|
|
|
select last_insert_id();
|
|
|
|
last_insert_id()
|
|
|
|
0
|
2006-09-01 16:51:37 +02:00
|
|
|
select * from t2;
|
|
|
|
k a c
|
2006-09-06 12:50:42 +02:00
|
|
|
1 6 2
|
2006-09-01 16:51:37 +02:00
|
|
|
2 7 NULL
|
|
|
|
insert ignore into t2 values (null,6,1),(10,8,1);
|
|
|
|
select last_insert_id();
|
|
|
|
last_insert_id()
|
2006-09-06 12:50:42 +02:00
|
|
|
0
|
2006-09-01 16:51:37 +02:00
|
|
|
insert ignore into t2 values (null,6,1),(null,8,1),(null,15,1),(null,20,1);
|
|
|
|
select last_insert_id();
|
|
|
|
last_insert_id()
|
|
|
|
11
|
|
|
|
select * from t2;
|
|
|
|
k a c
|
2006-09-06 12:50:42 +02:00
|
|
|
1 6 2
|
|
|
|
2 7 NULL
|
|
|
|
10 8 1
|
|
|
|
11 15 1
|
|
|
|
12 20 1
|
|
|
|
insert into t2 ( a ) values ( 6 ) on duplicate key update c =
|
|
|
|
ifnull( c,
|
|
|
|
0 ) + 1, k=last_insert_id(k);
|
|
|
|
select last_insert_id();
|
|
|
|
last_insert_id()
|
|
|
|
1
|
|
|
|
select * from t2;
|
|
|
|
k a c
|
|
|
|
1 6 3
|
2006-09-01 16:51:37 +02:00
|
|
|
2 7 NULL
|
|
|
|
10 8 1
|
|
|
|
11 15 1
|
|
|
|
12 20 1
|
|
|
|
drop table t2;
|
2007-05-14 20:38:26 +02:00
|
|
|
drop table if exists t1, t2;
|
|
|
|
create table t1 (i int);
|
|
|
|
alter table t1 modify i int default 1;
|
|
|
|
alter table t1 modify i int default 2, rename t2;
|
|
|
|
lock table t2 write;
|
|
|
|
alter table t2 modify i int default 3;
|
|
|
|
unlock tables;
|
|
|
|
lock table t2 write;
|
|
|
|
alter table t2 modify i int default 4, rename t1;
|
|
|
|
unlock tables;
|
|
|
|
drop table t1;
|
2007-05-19 08:49:56 +02:00
|
|
|
drop table if exists t1;
|
|
|
|
create table t1 (i int);
|
|
|
|
insert into t1 values ();
|
|
|
|
lock table t1 write;
|
|
|
|
alter table t1 modify i int default 1;
|
|
|
|
insert into t1 values ();
|
|
|
|
select * from t1;
|
|
|
|
i
|
|
|
|
NULL
|
|
|
|
1
|
|
|
|
alter table t1 change i c char(10) default "Two";
|
|
|
|
insert into t1 values ();
|
|
|
|
select * from t1;
|
|
|
|
c
|
|
|
|
NULL
|
|
|
|
1
|
|
|
|
Two
|
|
|
|
unlock tables;
|
|
|
|
select * from t1;
|
|
|
|
c
|
|
|
|
NULL
|
|
|
|
1
|
|
|
|
Two
|
|
|
|
drop tables t1;
|
2006-10-26 01:14:32 +02:00
|
|
|
End of 5.1 tests
|