Commit 55baa0c5 authored by MySQL Build Team's avatar MySQL Build Team

Backport into build-200909221805-5.1.37sp1

> ------------------------------------------------------------
> revno: 3085 [merge]
> revision-id: sergey.glukhov@sun.com-20090827105925-j56pdghdzb8nlw3p
> parent: alfranio.correia@sun.com-20090827093227-9exafl3k6362bvq7
> parent: sergey.glukhov@sun.com-20090827102219-sgjz0v5t1rfccs14
> committer: Sergey Glukhov <Sergey.Glukhov@sun.com>
> branch nick: mysql-5.1-bugteam
> timestamp: Thu 2009-08-27 15:59:25 +0500
> message:
>   5.0-bugteam->5.1-bugteam merge
> ------------------------------------------------------------
> Use --include-merges or -n0 to see merged revisions.
parent 7d520f51
...@@ -28,9 +28,7 @@ test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL ...@@ -28,9 +28,7 @@ test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
drop table t1,t2; drop table t1,t2;
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
id select_type table type possible_keys key key_len ref rows Extra ERROR HY000: Incorrect usage of PROCEDURE and subquery
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
create table t1 (a int not null); create table t1 (a int not null);
create table t2 select * from t1 where 0=1 procedure analyse(); create table t2 select * from t1 where 0=1 procedure analyse();
show create table t2; show create table t2;
...@@ -153,4 +151,9 @@ select f3 from t1 procedure analyse(1, 1); ...@@ -153,4 +151,9 @@ select f3 from t1 procedure analyse(1, 1);
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.f3 5.99999 9.55555 7 7 0 0 7.77777 1.77778 FLOAT(6,5) NOT NULL test.t1.f3 5.99999 9.55555 7 7 0 0 7.77777 1.77778 FLOAT(6,5) NOT NULL
drop table t1; drop table t1;
CREATE TABLE t1(a INT,b INT,c INT,d INT,e INT,f INT,g INT,h INT,i INT,j INT,k INT);
INSERT INTO t1 VALUES ();
SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE();
ERROR HY000: Incorrect usage of PROCEDURE and subquery
DROP TABLE t1;
End of 4.1 tests End of 4.1 tests
...@@ -75,7 +75,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); ...@@ -75,7 +75,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
ERROR HY000: Incorrect usage of PROCEDURE and subquery ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
ERROR HY000: Incorrect parameters to procedure 'ANALYSE' ERROR HY000: Incorrect usage of PROCEDURE and subquery
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
ERROR 42S22: Unknown column 'a' in 'field list' ERROR 42S22: Unknown column 'a' in 'field list'
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL; SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
......
...@@ -14,6 +14,7 @@ create table t2 select * from t1 procedure analyse(); ...@@ -14,6 +14,7 @@ create table t2 select * from t1 procedure analyse();
select * from t2; select * from t2;
drop table t1,t2; drop table t1,t2;
--error ER_WRONG_USAGE
EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
# #
...@@ -102,4 +103,13 @@ select f2 from t1 procedure analyse(1, 1); ...@@ -102,4 +103,13 @@ select f2 from t1 procedure analyse(1, 1);
select f3 from t1 procedure analyse(1, 1); select f3 from t1 procedure analyse(1, 1);
drop table t1; drop table t1;
#
# Bug#46184 Crash, SELECT ... FROM derived table procedure analyze
#
CREATE TABLE t1(a INT,b INT,c INT,d INT,e INT,f INT,g INT,h INT,i INT,j INT,k INT);
INSERT INTO t1 VALUES ();
--error ER_WRONG_USAGE
SELECT * FROM (SELECT * FROM t1) d PROCEDURE ANALYSE();
DROP TABLE t1;
--echo End of 4.1 tests --echo End of 4.1 tests
...@@ -30,7 +30,7 @@ SELECT 1 IN (SELECT 1); ...@@ -30,7 +30,7 @@ SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
-- error ER_WRONG_USAGE -- error ER_WRONG_USAGE
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1)); select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
-- error ER_WRONG_PARAMETERS_TO_PROCEDURE -- error ER_WRONG_USAGE
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1)); SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
-- error ER_BAD_FIELD_ERROR -- error ER_BAD_FIELD_ERROR
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL; SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
......
...@@ -9069,7 +9069,8 @@ procedure_clause: ...@@ -9069,7 +9069,8 @@ procedure_clause:
MYSQL_YYABORT; MYSQL_YYABORT;
} }
if (&lex->select_lex != lex->current_select) if (&lex->select_lex != lex->current_select ||
lex->select_lex.get_table_list()->derived)
{ {
my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "subquery"); my_error(ER_WRONG_USAGE, MYF(0), "PROCEDURE", "subquery");
MYSQL_YYABORT; MYSQL_YYABORT;
......
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