~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/derived.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-12-17 04:48:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1246.
  • Revision ID: osullivan.padraig@gmail.com-20091217044859-qorpkp4911zypfv3
Added some dtrace probes for tracing the optimizer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
--enable_warnings
5
5
 
6
6
select * from (select 2) b;
7
 
--error ER_BAD_FIELD_ERROR
 
7
-- error 1054
8
8
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
9
 
--error ER_BAD_FIELD_ERROR
 
9
-- error 1054
10
10
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
11
11
CREATE TABLE t1 (a int not null, b char (10) not null);
12
12
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
17
17
CREATE TABLE t3 (a int not null, b char (10) not null);
18
18
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
19
19
select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5  where t2.b=t5.b) as t4  where t1.a = t4.y;
20
 
--error ER_BAD_FIELD_ERROR
 
20
--error 1054
21
21
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
22
 
--error ER_NON_UNIQ_ERROR
 
22
--error 1052
23
23
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b  HAVING a=1;
24
24
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
25
25
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
26
 
--error ER_BAD_FIELD_ERROR
 
26
--error 1054
27
27
SELECT 1 FROM (SELECT 1) a WHERE a=2;
28
 
--error ER_BAD_FIELD_ERROR
 
28
--error 1054
29
29
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1  HAVING a=1) as a;
30
 
--sort_result
31
 
select * from t1 as x1, (select * from t1) as x2 where x1.a != 0;
32
 
explain select * from t1 as x1, (select * from t1) as x2 where x1.a != 0;
 
30
select * from t1 as x1, (select * from t1) as x2;
 
31
explain select * from t1 as x1, (select * from t1) as x2;
33
32
drop table if exists  t2,t3;
34
33
select * from (select 1) as a;
35
34
select a from (select 1 as a) as b;
58
57
enable_query_log;
59
58
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a  ASC LIMIT 0,20;
60
59
--replace_column 9 X
61
 
explain select count(*) from t1 as tt1, (select * from t1) as tt2 where tt1.a != 0;
 
60
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
62
61
drop table t1;
63
62
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
64
63
select * from (select 1 as a) b  left join (select 2 as a) c using(a);
65
 
--error ER_BAD_FIELD_ERROR
 
64
--error 1054
66
65
SELECT * FROM (SELECT 1 UNION SELECT a) b;
67
 
--error ER_BAD_FIELD_ERROR
 
66
--error 1054
68
67
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
69
 
--error ER_BAD_FIELD_ERROR
 
68
--error 1054
70
69
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
71
 
--error ER_BAD_FIELD_ERROR
 
70
--error 1054
72
71
select 1 from  (select 2) a order by 0;
73
72
 
74
73
#
105
104
#
106
105
create table t1 (a int);
107
106
insert into t1 values (1),(2),(3);
108
 
--error ER_PARSE_ERROR
 
107
-- error 1064
109
108
delete from (select * from t1);
110
 
--error ER_PARSE_ERROR
 
109
-- error 1064
111
110
insert into  (select * from t1) values (5);
112
111
drop table t1;
113
112
 
117
116
create table t1 (E1 INTEGER NOT NULL, E2 INTEGER NOT NULL, E3 INTEGER NOT NULL, PRIMARY KEY(E1)
118
117
);
119
118
insert into t1 VALUES(1,1,1), (2,2,1);
120
 
--sort_result
121
119
select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
122
120
explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
123
121
drop table t1;
124
122
 
125
123
create table t1 (a int);
126
124
insert into t1 values (1),(2);
127
 
--sort_result
128
 
select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b where a.a != 0;
129
 
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b where a.a != 0;
 
125
select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
 
126
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
130
127
drop table t1;
131
128
 
132
129
#
200
197
#
201
198
CREATE TABLE t1 (a char(10), b char(10));
202
199
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
203
 
--error ER_SUBQUERY_NO_1_ROW
 
200
--error 1242
204
201
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
205
202
DROP TABLE t1;
206
203
#
221
218
#
222
219
create table t1 (a int);
223
220
create table t2 (a int);
224
 
select * from (select * from t1,t2 where t1.a != 0) foo;
 
221
select * from (select * from t1,t2) foo;
225
222
drop table t1,t2;
226
223
 
227
224
#