From: Martin Hansson Date: December 13 2010 12:26pm Subject: Re: bzr commit into mysql-5.1-bugteam branch (sergey.glukhov:3515) Bug#48916 List-Archive: http://lists.mysql.com/commits/126626 Message-Id: <4D061105.7050908@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sergey Glukhov skrev 2010-12-10 13.06: > #At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:bjorn.munch@stripped > > 3515 Sergey Glukhov 2010-12-10 > Bug#48916 Server incorrectly processing HAVING clauses with an ORDER BY clause > Before sorting HAVING condition is splitted into two parts, > first past is a table related condition and the rest of is > HAVING part. Extraction of HAVING part does not take into account > the fact that some of conditions might be non-const but > have 'used_tables' == 0 (undependent subqueries) > and because of that these conditions are cut off by > make_cond_for_table() function. > The fix is to use (table_map) 0 instead of used_tables in > third argument for make_cond_for_table() function. > It allows to extract elements which belong to sorted > table and in addition elements which are undependend > subqueries. You might want to run a spell-checker on the comment. Misspelled change set comments take longer to read. I don't understand your fix. Ok, I understand that the IN condition is non-constant but still doesn't refer to any tables. But why is there any difference between sending a constant 0 and a variable which is 0? Actually, I ran some test on my machine and I get used_tables == 1. Have I missed something? I ran the test with your fix and as you're saying, the condition ((3,2),(select 4,2 having ((((3) = 4) or isnull(4)) and (((2) = 2) or isnull(2)) and (4) and (2)))) goes missing without your fix, but why? Best Regards Martin