mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
added mem_root switching for subselect if it is necessary
(bug #518 fixed)
This commit is contained in:
@@ -1134,3 +1134,17 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref salary salary 5 const 1 Using where
|
||||
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
ID int(10) unsigned NOT NULL auto_increment,
|
||||
SUB_ID int(3) unsigned NOT NULL default '0',
|
||||
REF_ID int(10) unsigned default NULL,
|
||||
REF_SUB int(3) unsigned default '0',
|
||||
PRIMARY KEY (ID,SUB_ID),
|
||||
UNIQUE KEY t1_PK (ID,SUB_ID),
|
||||
KEY t1_FK (REF_ID,REF_SUB),
|
||||
KEY t1_REFID (REF_ID)
|
||||
) TYPE=MyISAM CHARSET=cp1251;
|
||||
INSERT INTO t1 VALUES (1,0,NULL,NULL),(2,0,NULL,NULL);
|
||||
SELECT DISTINCT REF_ID FROM t1 WHERE ID= (SELECT DISTINCT REF_ID FROM t1 WHERE ID=2);
|
||||
REF_ID
|
||||
DROP TABLE t1;
|
||||
|
@@ -716,3 +716,17 @@ create table t1 (id int not null auto_increment primary key, salary int, key(sal
|
||||
insert into t1 (salary) values (100),(1000),(10000),(10),(500),(5000),(50000);
|
||||
explain SELECT id FROM t1 where salary = (SELECT MAX(salary) FROM t1);
|
||||
drop table t1;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
ID int(10) unsigned NOT NULL auto_increment,
|
||||
SUB_ID int(3) unsigned NOT NULL default '0',
|
||||
REF_ID int(10) unsigned default NULL,
|
||||
REF_SUB int(3) unsigned default '0',
|
||||
PRIMARY KEY (ID,SUB_ID),
|
||||
UNIQUE KEY t1_PK (ID,SUB_ID),
|
||||
KEY t1_FK (REF_ID,REF_SUB),
|
||||
KEY t1_REFID (REF_ID)
|
||||
) TYPE=MyISAM CHARSET=cp1251;
|
||||
INSERT INTO t1 VALUES (1,0,NULL,NULL),(2,0,NULL,NULL);
|
||||
SELECT DISTINCT REF_ID FROM t1 WHERE ID= (SELECT DISTINCT REF_ID FROM t1 WHERE ID=2);
|
||||
DROP TABLE t1;
|
||||
|
Reference in New Issue
Block a user