~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/r/explain.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
Import upstream version 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1;
 
2
create table t1 (id int not null, str char(10), unique(str));
 
3
explain select * from t1;
 
4
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
5
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    0       const row not found
 
6
insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
 
7
select * from t1 where str is null;
 
8
id      str
 
9
1       NULL
 
10
2       NULL
 
11
select * from t1 where str="foo";
 
12
id      str
 
13
3       foo
 
14
explain select * from t1 where str is null;
 
15
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
16
1       SIMPLE  t1      ref     str     str     11      const   1       Using where
 
17
explain select * from t1 where str="foo";
 
18
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
19
1       SIMPLE  t1      const   str     str     11      const   1       
 
20
explain select * from t1 ignore key (str) where str="foo";
 
21
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
22
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    4       Using where
 
23
explain select * from t1 use key (str,str) where str="foo";
 
24
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
25
1       SIMPLE  t1      const   str     str     11      const   1       
 
26
explain select * from t1 use key (str,str,foo) where str="foo";
 
27
ERROR 42000: Key 'foo' doesn't exist in table 't1'
 
28
explain select * from t1 ignore key (str,str,foo) where str="foo";
 
29
ERROR 42000: Key 'foo' doesn't exist in table 't1'
 
30
drop table t1;
 
31
explain select 1;
 
32
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
33
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
34
create table t1 (a int not null);
 
35
explain select count(*) from t1;
 
36
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
37
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
38
insert into t1 values(1);
 
39
explain select count(*) from t1;
 
40
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
41
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
42
insert into t1 values(1);
 
43
explain select count(*) from t1;
 
44
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
45
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Select tables optimized away
 
46
drop table t1;
 
47
set names koi8r;
 
48
create table ��� (���0 int, ���1 int, key ���0 (���0), key ���01 (���0,���1));
 
49
insert into ��� (���0) values (1);
 
50
insert into ��� (���0) values (2);
 
51
explain select ���0 from ��� where ���0=1;
 
52
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
53
1       SIMPLE  ���     ref     ���0,���01      ���0    5       const   1       Using where; Using index
 
54
drop table ���;
 
55
set names latin1;
 
56
select 3 into @v1;
 
57
explain select 3 into @v1;
 
58
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
59
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
60
create table t1(f1 int, f2 int);
 
61
insert into t1 values (1,1);
 
62
create view v1 as select * from t1 where f1=1;
 
63
explain extended select * from v1 where f2=1;
 
64
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
65
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
66
Warnings:
 
67
Note    1003    select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
 
68
explain extended select * from t1 where 0;
 
69
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
70
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
 
71
Warnings:
 
72
Note    1003    select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` where 0
 
73
explain extended select * from t1 where 1;
 
74
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
75
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
76
Warnings:
 
77
Note    1003    select '1' AS `f1`,'1' AS `f2` from `test`.`t1` where 1
 
78
explain extended select * from t1 having 0;
 
79
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
80
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible HAVING
 
81
Warnings:
 
82
Note    1003    select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` having 0
 
83
explain extended select * from t1 having 1;
 
84
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
85
1       SIMPLE  t1      system  NULL    NULL    NULL    NULL    1       100.00  
 
86
Warnings:
 
87
Note    1003    select '1' AS `f1`,'1' AS `f2` from `test`.`t1` having 1
 
88
drop view v1;
 
89
drop table t1;
 
90
CREATE TABLE t1(c INT);
 
91
INSERT INTO t1 VALUES (),();
 
92
CREATE TABLE t2 (b INT,
 
93
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
94
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
95
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
96
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
97
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
98
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
99
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b),
 
100
KEY(b),KEY(b),KEY(b),KEY(b),KEY(b));
 
101
INSERT INTO t2 VALUES (),(),();
 
102
EXPLAIN SELECT 1 FROM
 
103
(SELECT 1 FROM t2,t1 WHERE b < c GROUP BY 1 LIMIT 1) AS d2;
 
104
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
105
X       X       X       X       X       X       X       X       X       const row not found
 
106
X       X       X       X       X       X       X       X       X       
 
107
X       X       X       X       X       X       X       X       X       Range checked for each record (index map: 0xFFFFFFFFFF)
 
108
DROP TABLE t2;
 
109
DROP TABLE t1;
 
110
CREATE TABLE t1(a INT);
 
111
CREATE TABLE t2(a INT);
 
112
INSERT INTO t1 VALUES (1),(2);
 
113
INSERT INTO t2 VALUES (1),(2);
 
114
EXPLAIN EXTENDED SELECT 1
 
115
FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1;
 
116
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
117
1       PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    2       100.00  
 
118
2       DERIVED t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using temporary; Using filesort
 
119
2       DERIVED t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using join buffer
 
120
Warnings:
 
121
Note    1003    select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
 
122
EXPLAIN EXTENDED SELECT 1
 
123
FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1;
 
124
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
125
1       PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    2       100.00  
 
126
2       DERIVED t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using temporary; Using filesort
 
127
2       DERIVED t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using join buffer
 
128
Warnings:
 
129
Note    1003    select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
 
130
prepare s1 from 
 
131
'EXPLAIN EXTENDED SELECT 1  
 
132
 FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1';
 
133
execute s1;
 
134
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
135
1       PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    2       100.00  
 
136
2       DERIVED t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using temporary; Using filesort
 
137
2       DERIVED t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using join buffer
 
138
Warnings:
 
139
Note    1003    select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
 
140
prepare s1 from 
 
141
'EXPLAIN EXTENDED SELECT 1  
 
142
 FROM (SELECT COUNT(DISTINCT t1.a) FROM t1,t2 GROUP BY t1.a) AS s1';
 
143
execute s1;
 
144
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
145
1       PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    2       100.00  
 
146
2       DERIVED t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using temporary; Using filesort
 
147
2       DERIVED t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using join buffer
 
148
Warnings:
 
149
Note    1003    select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
 
150
execute s1;
 
151
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
152
1       PRIMARY <derived2>      ALL     NULL    NULL    NULL    NULL    2       100.00  
 
153
2       DERIVED t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using temporary; Using filesort
 
154
2       DERIVED t2      ALL     NULL    NULL    NULL    NULL    2       100.00  Using join buffer
 
155
Warnings:
 
156
Note    1003    select 1 AS `1` from (select count(distinct `test`.`t1`.`a`) AS `COUNT(DISTINCT t1.a)` from `test`.`t1` join `test`.`t2` group by `test`.`t1`.`a`) `s1`
 
157
DROP TABLE t1,t2;
 
158
CREATE TABLE t1 (a INT PRIMARY KEY);
 
159
EXPLAIN EXTENDED SELECT COUNT(a) FROM t1 USE KEY(a);
 
160
ERROR 42000: Key 'a' doesn't exist in table 't1'
 
161
DROP TABLE t1;
 
162
CREATE TABLE t1(a LONGTEXT);
 
163
INSERT INTO t1 VALUES (repeat('a',@@global.max_allowed_packet));
 
164
INSERT INTO t1 VALUES (repeat('b',@@global.max_allowed_packet));
 
165
EXPLAIN SELECT DISTINCT 1 FROM t1,
 
166
(SELECT DISTINCTROW a AS away FROM t1 GROUP BY a WITH ROLLUP) as d1
 
167
WHERE t1.a = d1.a;
 
168
ERROR 42S22: Unknown column 'd1.a' in 'where clause'
 
169
DROP TABLE t1;
 
170
#
 
171
# Bug#37870: Usage of uninitialized value caused failed assertion.
 
172
#
 
173
create table t1 (dt datetime not null, t time not null);
 
174
create table t2 (dt datetime not null);
 
175
insert into t1 values ('2001-01-01 1:1:1', '1:1:1'),
 
176
('2001-01-01 1:1:1', '1:1:1');
 
177
insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1');
 
178
flush tables;
 
179
EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL );
 
180
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
181
1       PRIMARY OUTR    ALL     NULL    NULL    NULL    NULL    2       Using where
 
182
2       DEPENDENT SUBQUERY      INNR    ALL     NULL    NULL    NULL    NULL    2       Using where
 
183
flush tables;
 
184
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL );
 
185
dt
 
186
flush tables;
 
187
EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
 
188
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
189
1       PRIMARY OUTR    ALL     NULL    NULL    NULL    NULL    2       Using where
 
190
2       DEPENDENT SUBQUERY      INNR    ALL     NULL    NULL    NULL    NULL    2       Using where
 
191
flush tables;
 
192
SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN ( SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.t < '2005-11-13 7:41:31' );
 
193
dt
 
194
2001-01-01 01:01:01
 
195
2001-01-01 01:01:01
 
196
drop tables t1, t2;
 
197
#
 
198
# Bug#48295:
 
199
# explain extended crash with subquery and ONLY_FULL_GROUP_BY sql_mode
 
200
#
 
201
CREATE TABLE t1 (f1 INT);
 
202
SELECT @@session.sql_mode INTO @old_sql_mode;
 
203
SET SESSION sql_mode='ONLY_FULL_GROUP_BY';
 
204
EXPLAIN EXTENDED SELECT 1 FROM t1
 
205
WHERE f1 > ALL( SELECT t.f1 FROM t1,t1 AS t );
 
206
ERROR 42000: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
 
207
SHOW WARNINGS;
 
208
Level   Code    Message
 
209
Error   1140    Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
 
210
Note    1003    select 1 AS `1` from `test`.`t1` where <not>(<exists>(...))
 
211
SET SESSION sql_mode=@old_sql_mode;
 
212
DROP TABLE t1;
 
213
End of 5.1 tests.