Bug #15463 EXPLAIN SELECT..INTO hangs the client (QB, command line)
Submitted: 3 Dec 2005 19:30 Modified: 22 May 2006 1:42
Reporter: Roland Bouman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0.17-BK, 5.0.16 OS:Linux (Linux, win xp)
Assigned to: Tomash Brechko CPU Architecture:Any

[3 Dec 2005 19:30] Roland Bouman
Description:
A EXPLAIN SELECT..INTO query hangs the client. The server remains up and is not extraordinarily busy. The MySQL Administrator reports the corresponding connection threads as 'sleeping'

This behaviour occurs in both the command line client and the query browser.
It seems to be independant of a particular SELECT. for example, it does not matter if there is a from list. 

When a create procedure statement is issued that contains such a SELECT, the client hangs as soon as the create procedure statement ends. The procedure is never created.

(IMO this latter observation suggests the error arises when parsing the statement)

In all cases, I did give it 5 minutes or so, then i killed the client

How to repeat:
explain select 1 into @id; 

(hanging now, ctrl+c helps in the command line client but QB is more troublesome)

delimiter //
create procedure pp()
begin
    declare v_id int;
    explain select 1 into v_id;
end;
//

(again, hanging now)

Suggested fix:
please remove the 

if (queryType = EXPLAIN and subtype = SELECT..INTO) then
    do hang_forever();
end if;

lines from the code ;-)
[4 Dec 2005 14:06] Valeriy Kravchuk
Thank you for a bug report. Verified just as described, also on 5.0.17-BK (ChangeSet@1.2041, 2005-12-01 15:10:35-08:00) on Linux.
[11 Apr 2006 8:15] Matthias Leich
Just for your information:
I discovered the same effect on my box with a slightly different
EXPLAIN SELECT ... INTO ...
   - Intel PC with Linux(SuSE 9.3)
   - MySQL compiled from source
         Version 5.1 last ChangeSet@1.2299, 2006-04-06 -- query hangs
         Version 5.0 last ChangeSet@1.2084, 2006-03-13 -- query hangs
         Version 4.1 last ChangeSet@1.2471, 2006-02-03 -- no problem !
[2 May 2006 15:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/5805
[2 May 2006 18:02] Tomash Brechko
Sorry, patch http://lists.mysql.com/commits/5805 is broken.
[3 May 2006 6:42] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/5847
[3 May 2006 11:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/5869
[3 May 2006 11:38] Konstantin Osipov
Approved by email.
[3 May 2006 14:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/5891
[18 May 2006 21:16] Dmitry Lenev
Fixed in 5.0.22 and 5.1.11
[22 May 2006 1:42] Paul DuBois
Noted in 5.0.22, 5.1.11 changelogs.

<literal>EXPLAIN ... SELECT INTO</literal> caused the client
to hang.