~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/derived.test

  • Committer: Andrew Hutchings
  • Date: 2010-09-08 19:03:09 UTC
  • mfrom: (1750 staging)
  • mto: (1750.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1751.
  • Revision ID: andrew@linuxjedi.co.uk-20100908190309-mya1nu7xvo1fpvk8
Merge trunk into branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 1054
 
20
--error ER_BAD_FIELD_ERROR
21
21
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
22
 
--error 1052
 
22
--error ER_NON_UNIQ_ERROR
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 1054
 
26
--error ER_BAD_FIELD_ERROR
27
27
SELECT 1 FROM (SELECT 1) a WHERE a=2;
28
 
--error 1054
 
28
--error ER_BAD_FIELD_ERROR
29
29
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1  HAVING a=1) as a;
 
30
--sort_result
30
31
select * from t1 as x1, (select * from t1) as x2;
31
32
explain select * from t1 as x1, (select * from t1) as x2;
32
33
drop table if exists  t2,t3;
61
62
drop table t1;
62
63
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
63
64
select * from (select 1 as a) b  left join (select 2 as a) c using(a);
64
 
--error 1054
 
65
--error ER_BAD_FIELD_ERROR
65
66
SELECT * FROM (SELECT 1 UNION SELECT a) b;
66
 
--error 1054
 
67
--error ER_BAD_FIELD_ERROR
67
68
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
68
 
--error 1054
 
69
--error ER_BAD_FIELD_ERROR
69
70
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
70
 
--error 1054
 
71
--error ER_BAD_FIELD_ERROR
71
72
select 1 from  (select 2) a order by 0;
72
73
 
73
74
#
116
117
create table t1 (E1 INTEGER NOT NULL, E2 INTEGER NOT NULL, E3 INTEGER NOT NULL, PRIMARY KEY(E1)
117
118
);
118
119
insert into t1 VALUES(1,1,1), (2,2,1);
 
120
--sort_result
119
121
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;
120
122
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;
121
123
drop table t1;
122
124
 
123
125
create table t1 (a int);
124
126
insert into t1 values (1),(2);
 
127
--sort_result
125
128
select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
126
129
explain select * from ( select * from t1 union select * from t1) a,(select * from t1 union select * from t1) b;
127
130
drop table t1;
197
200
#
198
201
CREATE TABLE t1 (a char(10), b char(10));
199
202
INSERT INTO t1 VALUES ('root','localhost'), ('root','%');
200
 
--error 1242
 
203
--error ER_SUBQUERY_NO_1_ROW
201
204
SELECT * FROM (SELECT (SELECT a.a FROM t1 AS a WHERE a.a = b.a) FROM t1 AS b) AS c;
202
205
DROP TABLE t1;
203
206
#