summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-12-26 01:28:59 +0200
committerunknown <bell@sanja.is.com.ua>2002-12-26 01:28:59 +0200
commit1dfa625f7b2a0767ce458c47122093a8c2ecf664 (patch)
tree6a73d0cc2b8728ab821e54448c158fa784365acb /mysql-test
parentda4d8e1b62edc5bc6f31d70279a619325ae69442 (diff)
downloadmariadb-git-1dfa625f7b2a0767ce458c47122093a8c2ecf664.tar.gz
support of subselect without FROM reducing (SCRUM)
fixed bug of calling setup_fields without correct lex->current_select pointer in mysql_derived more correct creation of reference in Item_field::fix_field mysql-test/r/subselect.result: new explain with subselect reduced mysql-test/t/subselect.test: new explain with subselect reduced sql/item.cc: support of subselect without FROM reducing more correct creation of reference in Item_field::fix_field sql/item.h: support of subselect without FROM reducing sql/item_cmpfunc.cc: support of subselect without FROM reducing sql/item_cmpfunc.h: support of subselect without FROM reducing sql/item_func.cc: support of subselect without FROM reducing sql/item_func.h: support of subselect without FROM reducing sql/item_row.cc: support of subselect without FROM reducing sql/item_row.h: support of subselect without FROM reducing sql/item_strfunc.h: fixed layout support of subselect without FROM reducing sql/item_subselect.cc: support of subselect without FROM reducing sql/item_subselect.h: support of subselect without FROM reducing sql/mysql_priv.h: reference in Item_field::fix_field related changes sql/sql_base.cc: reference in Item_field::fix_field related changes sql/sql_derived.cc: fixed bug of calling setup_fields without correct lex->current_select pointer
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/subselect.result33
-rw-r--r--mysql-test/t/subselect.test6
2 files changed, 38 insertions, 1 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 502fe0fad60..23aad50c6ae 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1,13 +1,32 @@
select (select 2);
(select 2)
2
+explain select (select 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1247 Select 2 was reduced during optimisation
SELECT (SELECT 1) UNION SELECT (SELECT 2);
(SELECT 1)
1
2
+explain SELECT (SELECT 1) UNION SELECT (SELECT 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1247 Select 2 was reduced during optimisation
+Note 1247 Select 4 was reduced during optimisation
SELECT (SELECT (SELECT 0 UNION SELECT 0));
(SELECT (SELECT 0 UNION SELECT 0))
0
+explain SELECT (SELECT (SELECT 0 UNION SELECT 0));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used
+4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1247 Select 2 was reduced during optimisation
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
Reference 'a' not supported (forward reference in item list)
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;
@@ -20,8 +39,9 @@ Reference 'a' not supported (forward reference in item list)
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
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
-3 DEPENDENT SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used
2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1247 Select 3 was reduced during optimisation
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
1
1
@@ -629,6 +649,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ref id id 5 const 1 Using where; Using index
3 SUBSELECT NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
+Note 1247 Select 3 was reduced during optimisation
Note 1247 Select 2 was reduced during optimisation
EXPLAIN SELECT * FROM t WHERE id IN (SELECT 1 UNION SELECT 3);
id select_type table type possible_keys key key_len ref rows Extra
@@ -752,6 +773,16 @@ NULL
select 10.5 > ANY (SELECT * from t);
10.5 > ANY (SELECT * from t)
1
+explain select (select a+1) from t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1247 Select 2 was reduced during optimisation
+select (select a+1) from t;
+(select a+1)
+2.5
+NULL
+4.5
drop table t;
create table t (a float);
select 10.5 IN (SELECT * from t LIMIT 1);
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index c77fc33f0ea..4e8e71e50f8 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1,6 +1,9 @@
select (select 2);
+explain select (select 2);
SELECT (SELECT 1) UNION SELECT (SELECT 2);
+explain SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0));
+explain SELECT (SELECT (SELECT 0 UNION SELECT 0));
-- error 1245
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
-- error 1245
@@ -424,6 +427,8 @@ select 1.5 > ALL (SELECT * from t);
select 10.5 > ALL (SELECT * from t);
select 1.5 > ANY (SELECT * from t);
select 10.5 > ANY (SELECT * from t);
+explain select (select a+1) from t;
+select (select a+1) from t;
drop table t;
#LIMIT is not supported now
@@ -433,6 +438,7 @@ select 10.5 IN (SELECT * from t LIMIT 1);
-- error 1235
select 10.5 IN (SELECT * from t LIMIT 1 UNION SELECT 1.5);
drop table t;
+
create table t1 (a int, b int, c varchar(10));
create table t2 (a int);
insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c');