1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
This commit is contained in:
unknown
2002-12-26 01:28:59 +02:00
parent da4d8e1b62
commit 1dfa625f7b
16 changed files with 223 additions and 34 deletions

View File

@ -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);

View File

@ -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');