From: Tor Didriksen Date: April 8 2011 5:53am Subject: Re: bzr commit into mysql-5.1 branch (tor.didriksen:3648) Bug#11765713 List-Archive: http://lists.mysql.com/commits/135013 Message-Id: <4D9EA2D5.7040905@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit On 2011-04-07 18:05, Guilhem Bichot wrote: > Hello Tor, > > Tor Didriksen a écrit, Le 07.04.2011 13:56: >> #At file:///export/home/didrik/repo/5.1-foo/ based on >> revid:georgi.kodinov@stripped >> >> 3648 Tor Didriksen 2011-04-07 >> Bug#11765713 58705: OPTIMIZER LET ENGINE DEPEND ON >> UNINITIALIZED VALUES CREATED BY OPT_SUM_QU >> @ mysql-test/r/subselect.result >> New test case. >> @ mysql-test/t/subselect.test >> New test case. >> @ sql/opt_sum.cc >> Add thd to opt_sum_query/matching_cond/find_key_for_maxmin, >> enabling them to test for errors. >> Return with error code if thd->is_error() rather than >> continuing to read the index. >> @ sql/sql_select.cc >> Add thd to opt_sum_query, enabling it to test for errors. >> @ sql/sql_select.h >> Add thd to opt_sum_query, enabling it to test for errors. >> > > Can you explain what the bug's plot was, without the code patch: what > function evaluated which subquery (there are several subqueries) and > what function set the error flag; what function failed to notice the > error flag and used a result which should not have been used, and did > what should not have been done... > I'm surprised that we need to add tests of thd->is_error() to more > than one place, hence my questions. > Thanks! Hi Guilhem Run the new testcase with --debug, and you will see what is going on. You may also want to apply this patch to _db_return_() --- dbug/dbug.c 2011-02-22 21:03:32 +0000 +++ dbug/dbug.c 2011-04-08 05:40:24 +0000 @@ -1071,7 +1071,7 @@ pthread_mutex_lock(&THR_LOCK_dbug); DoPrefix(cs, _line_); Indent(cs, cs->level); - (void) fprintf(cs->stack->out_file, "<%s\n", cs->func); + (void) fprintf(cs->stack->out_file, "<%s %d\n", cs->func, _line_); Please also read the discussion between gluh and myself about the first version of the patch. The innermost subquery returns two rows, which makes 'a <=> (subquery)' fail. matching_cond() wasn't prepared for it, hence the new lines checking for thd->is_error() -- didrik