Re: "strange" EXPLAIN result of a subselect ?

Re: "strange" EXPLAIN result of a subselect ?

am 18.11.2002 19:40:39 von Sinisa Milivojevic

Jocelyn Fournier writes:
> Hi,
>
> Peharps try to use my table ;), or try to add a row in titles table so that
> "select 1 from titles where number = 1" returns more than one row.
>
> Without EXPLAIN, the query should return :
>
> SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND
> numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1');
> ERROR 1240: Subselect returns more than 1 record
>
> Here is my table :
>
> CREATE TABLE `threadhardwarefr7` (
> `numeropost` mediumint(8) unsigned NOT NULL default '0',
> `numreponse` int(10) unsigned NOT NULL auto_increment,
> PRIMARY KEY (`numeropost`,`numreponse`),
> UNIQUE KEY `numreponse` (`numreponse`)
> ) TYPE=MyISAM
>
> INSERT INTO threadhardwarefr7 VALUES (1,1),(1,2);
>
> Regards,
> Jocelyn
>

Thank you for explaining how to repeat a bug.

It is now fixed with this patch:

===== sql/sql_class.cc 1.100 vs edited =====
*** /tmp/sql_class.cc-1.100-2789 Thu Nov 14 09:43:23 2002
--- edited/sql/sql_class.cc Mon Nov 18 19:58:48 2002
***************
*** 882,888 ****
DBUG_ENTER("select_singleval_subselect::send_data");
Item_singleval_subselect *it= (Item_singleval_subselect *)item;
if (it->assigned()){
! my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0));
DBUG_RETURN(1);
}
if (unit->offset_limit_cnt)
--- 882,889 ----
DBUG_ENTER("select_singleval_subselect::send_data");
Item_singleval_subselect *it= (Item_singleval_subselect *)item;
if (it->assigned()){
! if (!current_thd->lex.describe)
! my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0));
DBUG_RETURN(1);
}
if (unit->offset_limit_cnt)

The above is a quick fix. We might change this by changing a class
itself, but we yet have to decide on that.

--
Regards,
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com


------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail bugs-thread13026@lists.mysql.com
To unsubscribe, e-mail