mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
fixed subselect explain bug
This commit is contained in:
@ -269,3 +269,21 @@ INSERT INTO iftest VALUES ();
|
||||
SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
|
||||
Subselect returns more than 1 record
|
||||
drop table iftest;
|
||||
drop table if exists threadhardwarefr7;
|
||||
CREATE TABLE `threadhardwarefr7` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL default '0',
|
||||
`numreponse` int(10) unsigned NOT NULL auto_increment,
|
||||
`pseudo` varchar(35) NOT NULL default '',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
UNIQUE KEY `numreponse` (`numreponse`),
|
||||
KEY `pseudo` (`pseudo`,`numeropost`)
|
||||
) TYPE=MyISAM;
|
||||
INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
|
||||
EXPLAIN SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE Select tables optimized away
|
||||
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY threadhardwarefr7 const PRIMARY,numreponse PRIMARY 7 const,const 1
|
||||
2 SUBSELECT Select tables optimized away
|
||||
drop table if exists threadhardwarefrtest7;
|
||||
|
@ -166,3 +166,18 @@ INSERT INTO iftest VALUES ();
|
||||
-- error 1240
|
||||
SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
|
||||
drop table iftest;
|
||||
|
||||
drop table if exists threadhardwarefr7;
|
||||
CREATE TABLE `threadhardwarefr7` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL default '0',
|
||||
`numreponse` int(10) unsigned NOT NULL auto_increment,
|
||||
`pseudo` varchar(35) NOT NULL default '',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
UNIQUE KEY `numreponse` (`numreponse`),
|
||||
KEY `pseudo` (`pseudo`,`numeropost`)
|
||||
) TYPE=MyISAM;
|
||||
INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
|
||||
|
||||
EXPLAIN SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1';
|
||||
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1');
|
||||
drop table if exists threadhardwarefrtest7;
|
||||
|
@ -395,13 +395,7 @@ JOIN::optimize()
|
||||
zero_result_cause= "No matching min/max row";
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (select_options & SELECT_DESCRIBE)
|
||||
{
|
||||
select_describe(this, false, false, false,
|
||||
"Select tables optimized away");
|
||||
delete procedure;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
zero_result_cause= "Select tables optimized away";
|
||||
tables_list= 0; // All tables resolved
|
||||
}
|
||||
}
|
||||
@ -663,7 +657,8 @@ JOIN::exec()
|
||||
{ // Only test of functions
|
||||
error=0;
|
||||
if (select_options & SELECT_DESCRIBE)
|
||||
select_describe(this, false, false, false, "No tables used");
|
||||
select_describe(this, false, false, false,
|
||||
(zero_result_cause?zero_result_cause:"No tables used"));
|
||||
else
|
||||
{
|
||||
result->send_fields(fields_list,1);
|
||||
|
Reference in New Issue
Block a user