Commit 959b3067 authored by Sinisa@sinisa.nasamreza.org's avatar Sinisa@sinisa.nasamreza.org

Merge sinisa@work.mysql.com:/home/bk/mysql-4.1

into sinisa.nasamreza.org:/mnt/work/mysql-4.1
parents fd11c804 5b7a2f56
...@@ -262,5 +262,6 @@ ...@@ -262,5 +262,6 @@
#define ER_CYCLIC_REFERENCE 1243 #define ER_CYCLIC_REFERENCE 1243
#define ER_AUTO_CONVERT 1244 #define ER_AUTO_CONVERT 1244
#define ER_ILLEGAL_REFERENCE 1245 #define ER_ILLEGAL_REFERENCE 1245
#define ER_SELECT_REDUCED 1246 #define ER_DERIVED_MUST_HAVE_ALIAS 1246
#define ER_ERROR_MESSAGES 247 #define ER_SELECT_REDUCED 1247
#define ER_ERROR_MESSAGES 248
...@@ -17,32 +17,32 @@ select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3 ...@@ -17,32 +17,32 @@ select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3
a y a y
3 3 3 3
3 3 3 3
SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1); SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
Unknown column 'a' in 'having clause' Unknown column 'a' in 'having clause'
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1; SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
Column: 'a' in having clause is ambiguous Column: 'a' in having clause is ambiguous
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2; SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
a a a a
1 2 1 2
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1; SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
a a a a
SELECT 1 FROM (SELECT 1) WHERE a=2; SELECT 1 FROM (SELECT 1) a WHERE a=2;
Unknown column 'a' in 'where clause' Unknown column 'a' in 'where clause'
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
Unknown column 'a' in 'having clause' Unknown column 'a' in 'having clause'
drop table if exists t1.t2,t3; drop table if exists t1.t2,t3;
select * from (select 1); select * from (select 1) as a;
1 1
1 1
select a from (select 1 as a); select a from (select 1 as a) as b;
a a
1 1
select 1 from (select 1); select 1 from (select 1) as a;
1 1
1 1
drop table if exists t1; drop table if exists t1;
create table t1(a int not null, t char(8), index(a)); create table t1(a int not null, t char(8), index(a));
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20; SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
a t a t
1 1 1 1
2 2 2 2
...@@ -64,7 +64,13 @@ a t ...@@ -64,7 +64,13 @@ a t
18 18 18 18
19 19 19 19
20 20 20 20
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Select tables optimized away
drop table if exists t1; drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a))); SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
(SELECT * FROM (SELECT 1 as a)) (SELECT * FROM (SELECT 1 as a) as a )
1 1
select * from (select 1 as a) b left join (select 2 as a) c using(a);
a a
1 NULL
SELECT 1 FROM (SELECT 1) GROUP BY SUM(1); SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
Invalid use of group function Invalid use of group function
drop table if exists t1,t2,t3; drop table if exists t1,t2,t3;
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -168,7 +168,7 @@ test2 2 2 ...@@ -168,7 +168,7 @@ test2 2 2
SELECT FOUND_ROWS(); SELECT FOUND_ROWS();
FOUND_ROWS() FOUND_ROWS()
2 2
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0; SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
1 1
SELECT FOUND_ROWS(); SELECT FOUND_ROWS();
FOUND_ROWS() FOUND_ROWS()
......
...@@ -8,29 +8,29 @@ SELECT (SELECT 1) UNION SELECT (SELECT 2); ...@@ -8,29 +8,29 @@ SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0)); SELECT (SELECT (SELECT 0 UNION SELECT 0));
(SELECT (SELECT 0 UNION SELECT 0)) (SELECT (SELECT 0 UNION SELECT 0))
0 0
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a; SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
Reference 'a' not supported (forward reference in item list) Reference 'a' not supported (forward reference in item list)
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b; SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
Reference 'b' not supported (forward reference in item list) Reference 'b' not supported (forward reference in item list)
SELECT (SELECT 1),MAX(1) FROM (SELECT 1); SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
(SELECT 1) MAX(1) (SELECT 1) MAX(1)
1 1 1 1
SELECT (SELECT a) as a; SELECT (SELECT a) as a;
Reference 'a' not supported (forward reference in item list) Reference 'a' not supported (forward reference in item list)
EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1; EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 1 PRIMARY <derived2> system NULL NULL NULL NULL 1
3 DEPENDENT SUBSELECT No tables used 3 DEPENDENT SUBSELECT No tables used
2 DERIVED No tables used 2 DERIVED No tables used
SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1; SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1 1
1 1
SELECT (SELECT 1), a; SELECT (SELECT 1), a;
Unknown column 'a' in 'field list' Unknown column 'a' in 'field list'
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1; SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
a a
1 1
SELECT 1 FROM (SELECT (SELECT a)); SELECT 1 FROM (SELECT (SELECT a) b) c;
Unknown column 'a' in 'field list' Unknown column 'a' in 'field list'
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1); SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
id id
...@@ -319,7 +319,7 @@ SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='j ...@@ -319,7 +319,7 @@ SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='j
numeropost maxnumrep numeropost maxnumrep
43506 2 43506 2
40143 1 40143 1
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
Unknown column 'a' in 'having clause' Unknown column 'a' in 'having clause'
SELECT 1 IN (SELECT 1 FROM t2 HAVING a); SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
Unknown column 'a' in 'having clause' Unknown column 'a' in 'having clause'
...@@ -368,7 +368,7 @@ Subselect returns more than 1 record ...@@ -368,7 +368,7 @@ Subselect returns more than 1 record
drop table t1; drop table t1;
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b'); CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO t1 VALUES (); INSERT INTO t1 VALUES ();
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b'); SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
Subselect returns more than 1 record Subselect returns more than 1 record
drop table t1; drop table t1;
CREATE TABLE `t1` ( CREATE TABLE `t1` (
...@@ -398,7 +398,7 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -398,7 +398,7 @@ id select_type table type possible_keys key key_len ref rows Extra
drop table t1; drop table t1;
CREATE TABLE t1 (a int(1)); CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1; SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
1 1
1 1
drop table t1; drop table t1;
......
...@@ -9,19 +9,19 @@ CREATE TABLE t3 (a int not null, b char (10) not null); ...@@ -9,19 +9,19 @@ CREATE TABLE t3 (a int not null, b char (10) not null);
insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c'); insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
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; 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;
--error 1054 --error 1054
SELECT a FROM (SELECT 1 FROM (SELECT 1) HAVING a=1); SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
--error 1052 --error 1052
SELECT a,b as a FROM (SELECT '1' as a,'2' as b) HAVING a=1; SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=2; SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
SELECT a,2 as a FROM (SELECT '1' as a) HAVING a=1; SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
--error 1054 --error 1054
SELECT 1 FROM (SELECT 1) WHERE a=2; SELECT 1 FROM (SELECT 1) a WHERE a=2;
--error 1054 --error 1054
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
drop table if exists t1.t2,t3; drop table if exists t1.t2,t3;
select * from (select 1); select * from (select 1) as a;
select a from (select 1 as a); select a from (select 1 as a) as b;
select 1 from (select 1); select 1 from (select 1) as a;
drop table if exists t1; drop table if exists t1;
create table t1(a int not null, t char(8), index(a)); create table t1(a int not null, t char(8), index(a));
disable_query_log; disable_query_log;
...@@ -32,6 +32,8 @@ while ($1) ...@@ -32,6 +32,8 @@ while ($1)
dec $1; dec $1;
} }
enable_query_log; enable_query_log;
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20; SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
explain select count(*) from t1 as tt1, (select * from t1) as tt2;
drop table if exists t1; drop table if exists t1;
SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a))); SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
select * from (select 1 as a) b left join (select 2 as a) c using(a);
-- error 1111 -- error 1111
SELECT 1 FROM (SELECT 1) GROUP BY SUM(1); SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
# #
# Test of group (Failed for Lars Hoss <lh@pbm.de>) # Test of group (Failed for Lars Hoss <lh@pbm.de>)
# #
......
...@@ -84,7 +84,7 @@ INSERT INTO t1 (titre,maxnumrep) VALUES ...@@ -84,7 +84,7 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
('test1','1'),('test2','2'),('test3','3'); ('test1','1'),('test2','2'),('test3','3');
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1; SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
SELECT FOUND_ROWS(); SELECT FOUND_ROWS();
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0; SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
SELECT FOUND_ROWS(); SELECT FOUND_ROWS();
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0; SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
SELECT FOUND_ROWS(); SELECT FOUND_ROWS();
......
...@@ -2,25 +2,25 @@ select (select 2); ...@@ -2,25 +2,25 @@ select (select 2);
SELECT (SELECT 1) UNION SELECT (SELECT 2); SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0)); SELECT (SELECT (SELECT 0 UNION SELECT 0));
-- error 1245 -- error 1245
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a; SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
-- error 1245 -- error 1245
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b; SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
SELECT (SELECT 1),MAX(1) FROM (SELECT 1); SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
-- error 1245 -- error 1245
SELECT (SELECT a) as a; SELECT (SELECT a) as a;
EXPLAIN SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1; EXPLAIN SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
SELECT 1 FROM (SELECT 1 as a) HAVING (SELECT a)=1; SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
-- error 1054 -- error 1054
SELECT (SELECT 1), a; SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1; SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
-- error 1054 -- error 1054
SELECT 1 FROM (SELECT (SELECT a) b) c;
SELECT 1 FROM (SELECT (SELECT a)); SELECT 1 FROM (SELECT (SELECT a));
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1); SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
-- error 1239 -- error 1239
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1); SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
SELECT 1 IN (SELECT 1); SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a)); SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
...@@ -176,7 +176,7 @@ INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce ...@@ -176,7 +176,7 @@ INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce
select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
-- error 1054 -- error 1054
SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
-- error 1054 -- error 1054
SELECT 1 IN (SELECT 1 FROM t2 HAVING a); SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date); SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY date);
...@@ -210,7 +210,7 @@ drop table t1; ...@@ -210,7 +210,7 @@ drop table t1;
CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b'); CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO t1 VALUES (); INSERT INTO t1 VALUES ();
-- error 1240 -- error 1240
SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b'); SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
drop table t1; drop table t1;
# threadhardwarefr7 # threadhardwarefr7
...@@ -236,7 +236,7 @@ drop table t1; ...@@ -236,7 +236,7 @@ drop table t1;
CREATE TABLE t1 (a int(1)); CREATE TABLE t1 (a int(1));
INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (1);
SELECT 1 FROM (SELECT a FROM t1) HAVING (SELECT a)=1; SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
drop table t1; drop table t1;
#update with subselects #update with subselects
......
...@@ -256,4 +256,5 @@ v/* ...@@ -256,4 +256,5 @@ v/*
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -250,4 +250,5 @@ ...@@ -250,4 +250,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -258,4 +258,5 @@ ...@@ -258,4 +258,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -252,4 +252,5 @@ ...@@ -252,4 +252,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -250,4 +250,5 @@ ...@@ -250,4 +250,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -249,4 +249,5 @@ ...@@ -249,4 +249,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -249,4 +249,5 @@ ...@@ -249,4 +249,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -249,4 +249,5 @@ ...@@ -249,4 +249,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -249,4 +249,5 @@ ...@@ -249,4 +249,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -251,4 +251,5 @@ ...@@ -251,4 +251,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -251,4 +251,5 @@ ...@@ -251,4 +251,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s" "Converting column '%s' from %s to %s"
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -250,4 +250,5 @@ ...@@ -250,4 +250,5 @@
" ", " ",
" '%s' %s %s", " '%s' %s %s",
" '%-.64s' (%s)", " '%-.64s' (%s)",
"Every derived table must have it's own alias"
"Select %u ", "Select %u ",
...@@ -243,4 +243,5 @@ ...@@ -243,4 +243,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -255,4 +255,5 @@ ...@@ -255,4 +255,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -248,4 +248,5 @@ ...@@ -248,4 +248,5 @@
"Cyclic reference on subqueries", "Cyclic reference on subqueries",
"Converting column '%s' from %s to %s", "Converting column '%s' from %s to %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -247,4 +247,5 @@ ...@@ -247,4 +247,5 @@
"Syklisk referens i subselect", "Syklisk referens i subselect",
"Konvertar kolumn '%s' från %s till %s", "Konvertar kolumn '%s' från %s till %s",
"Reference '%-.64s' not supported (%s)", "Reference '%-.64s' not supported (%s)",
"Every derived table must have it's own alias"
"Select %u was reduced during optimisation", "Select %u was reduced during optimisation",
...@@ -252,4 +252,5 @@ ...@@ -252,4 +252,5 @@
"̦ Ц", "̦ Ц",
" '%s' %s %s", " '%s' %s %s",
" '%-.64s' i (%s)", " '%-.64s' i (%s)",
"Every derived table must have it's own alias"
"Select %u was iii", "Select %u was iii",
...@@ -1894,13 +1894,13 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, ...@@ -1894,13 +1894,13 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
const char *name=item->field_name; const char *name=item->field_name;
uint length=(uint) strlen(name); uint length=(uint) strlen(name);
if (table_name) if (table_name && table_name[0])
{ /* Qualified field */ { /* Qualified field */
bool found_table=0; bool found_table=0;
for (; tables ; tables=tables->next) for (; tables ; tables=tables->next)
{ {
if (!strcmp(tables->alias,table_name) && if (!strcmp(tables->alias,table_name) &&
(!db || !strcmp(db,tables->db))) (!db || !tables->db || !tables->db[0] || !strcmp(db,tables->db)))
{ {
found_table=1; found_table=1;
Field *find=find_field_in_table(thd,tables->table,name,length, Field *find=find_field_in_table(thd,tables->table,name,length,
......
...@@ -106,7 +106,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t) ...@@ -106,7 +106,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t)
t->table=table; t->table=table;
table->derived_select_number= sl->select_number; table->derived_select_number= sl->select_number;
table->tmp_table=TMP_TABLE; table->tmp_table=TMP_TABLE;
if (!lex->describe) if (lex->describe)
sl->exclude(); sl->exclude();
t->db=(char *)""; t->db=(char *)"";
t->derived=(SELECT_LEX *)0; // just in case ... t->derived=(SELECT_LEX *)0; // just in case ...
......
...@@ -1205,6 +1205,8 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex, ...@@ -1205,6 +1205,8 @@ bool st_select_lex_unit::create_total_list_n_last_return(THD *thd, st_lex *lex,
net_printf(thd,ER_WRONG_USAGE,"UNION","ORDER BY"); net_printf(thd,ER_WRONG_USAGE,"UNION","ORDER BY");
return 1; return 1;
} }
if (sl->linkage == DERIVED_TABLE_TYPE)
continue;
for (SELECT_LEX_UNIT *inner= sl->first_inner_unit(); for (SELECT_LEX_UNIT *inner= sl->first_inner_unit();
inner; inner;
inner= inner->next_unit()) inner= inner->next_unit())
......
...@@ -3410,8 +3410,15 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table, ...@@ -3410,8 +3410,15 @@ TABLE_LIST *st_select_lex::add_table_to_list(Table_ident *table,
} }
if (!alias) /* Alias is case sensitive */ if (!alias) /* Alias is case sensitive */
{
if (table->sel)
{
net_printf(thd,ER_DERIVED_MUST_HAVE_ALIAS);
DBUG_RETURN(0);
}
if (!(alias_str=thd->memdup(alias_str,table->table.length+1))) if (!(alias_str=thd->memdup(alias_str,table->table.length+1)))
DBUG_RETURN(0); DBUG_RETURN(0);
}
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST)))) if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
DBUG_RETURN(0); /* purecov: inspected */ DBUG_RETURN(0); /* purecov: inspected */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment