3
2
drop table if exists t1,t2,t3;
6
4
select * from (select 2) b;
7
--error ER_BAD_FIELD_ERROR
8
6
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
9
--error ER_BAD_FIELD_ERROR
10
8
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
11
9
CREATE TABLE t1 (a int not null, b char (10) not null);
12
10
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
17
15
CREATE TABLE t3 (a int not null, b char (10) not null);
18
16
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
19
17
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
21
19
SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
22
--error ER_NON_UNIQ_ERROR
23
21
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
24
22
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
25
23
SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
26
--error ER_BAD_FIELD_ERROR
27
25
SELECT 1 FROM (SELECT 1) a WHERE a=2;
28
--error ER_BAD_FIELD_ERROR
29
27
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
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;
28
select * from t1 as x1, (select * from t1) as x2;
29
explain select * from t1 as x1, (select * from t1) as x2;
33
30
drop table if exists t2,t3;
34
31
select * from (select 1) as a;
35
32
select a from (select 1 as a) as b;
59
56
SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
60
57
--replace_column 9 X
61
explain select count(*) from t1 as tt1, (select * from t1) as tt2 where tt1.a != 0;
58
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
63
60
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
64
61
select * from (select 1 as a) b left join (select 2 as a) c using(a);
65
--error ER_BAD_FIELD_ERROR
66
63
SELECT * FROM (SELECT 1 UNION SELECT a) b;
67
--error ER_BAD_FIELD_ERROR
68
65
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
69
--error ER_BAD_FIELD_ERROR
70
67
SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
71
--error ER_BAD_FIELD_ERROR
72
69
select 1 from (select 2) a order by 0;
117
116
create table t1 (E1 INTEGER NOT NULL, E2 INTEGER NOT NULL, E3 INTEGER NOT NULL, PRIMARY KEY(E1)
119
118
insert into t1 VALUES(1,1,1), (2,2,1);
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;
125
123
create table t1 (a int);
126
124
insert into t1 values (1),(2);
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
# multi-update & multi-delete with derived tables
133
`N` int NOT NULL default '0',
136
INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0);
137
UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
140
# TODO: Bug lp:311109
141
#UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2;
143
UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2;
144
delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
146
--replace_result P2 p2
147
# TODO: Bug lp:311111
148
#--error ER_NON_UPDATABLE_TABLE
149
#delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
151
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
133
155
# correct lex->current_select
135
CREATE TEMPORARY TABLE t1 (
136
158
OBJECTID int NOT NULL default 0,
137
159
SORTORDER int NOT NULL auto_increment,
138
160
KEY t1_SortIndex (SORTORDER),
139
161
KEY t1_IdIndex (OBJECTID)
141
CREATE TEMPORARY TABLE t2 (
142
164
ID int default NULL,
143
165
PARID int default NULL,
144
166
UNIQUE KEY t2_ID_IDX (ID),
145
167
KEY t2_PARID_IDX (PARID)
147
169
INSERT INTO t2 VALUES (1000,0),(1001,0),(1002,0),(1003,0),(1008,1),(1009,1),(1010,1),(1011,1),(1016,2);
148
CREATE TEMPORARY TABLE t3 (
149
171
ID int default NULL,
150
172
DATA decimal(10,2) default NULL,
151
173
UNIQUE KEY t3_ID_IDX (ID)