Bug #5382 Server crashes after writing INTO OUTFILE
Submitted: 3 Sep 2004 6:12 Modified: 10 Oct 2004 10:32
Reporter: Adrian McElligott Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1 [MySqlCC 0.9.4 (beta)] OS:Any (any)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[3 Sep 2004 6:12] Adrian McElligott
Description:
The following command consistently causes the MySql service to stop shortly after the command appears to have executed successfully.
SELECT *
  INTO OUTFILE 'c:/temp/help_topic.txt' 
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
  LINES TERMINATED BY '\r\n' 
  FROM `help_topic`
  LIMIT 10

Works OK with 4.0 [MySqlCC 0.9.4 (beta)]
Works OK from command line.

How to repeat:
Execute 

SELECT *
  INTO OUTFILE 'c:/temp/help_topic.txt' 
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
  LINES TERMINATED BY '\r\n' 
  FROM `help_topic`
  LIMIT 10

from within 4.1 [MySqlCC 0.9.4 (beta)] 

The output panel shows:
Query OK, 390 rows affected (0.02) sec
[<hostname>] ERROR 2013: Lost connection to MySQL server during query

Note: I got the same result on every table that I tested - not just the `help_topic` table.
[3 Sep 2004 11:23] Sergei Golubchik
ERROR 2013: Lost connection to MySQL server during query

can really mean two things, either the client (MySQLCC) disconnected for some reason, or the server indeed crashed.

Two distinguish between these two cases, could you connect from command line mysql.exe and then execute this LOAD DATA from MySQLCC (while keeping the connection in mysql.exe open) ? Then executing any query, e.g. SELECT 1;
from command line you will find out whether only a connection to MySQLCC was broken or the server crashed.
[3 Sep 2004 14:47] Adrian McElligott
Yes, I can confirm that the actual MySql service running on the database server did stop, and needed to be restarted between each test.

More info: I have now reproduced the same behaviour on a differant server.
[8 Oct 2004 9:28] Lynn Prentice
Reproduced on Windows 2000 server fully patched.
In MySQl versions 4.1.4 and 4.1.5 running as a service.
SELECT *
  INTO OUTFILE 'c:/temp/xxx1.txt' 
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
  LINES TERMINATED BY '\r\n' 
  FROM `company_out`
In mysqlcc 0.9.4-beta both version and ODBC 3.51.7 in 4.1.4.
The output file creates sucessfully. 
Looks like a mysqld server bug because the error from the OS is :-
mysqld-nt.exe : The instruction at "0x004c23df" referenced memory at :0x00000004". The memory could not be written. 
You may be able to use the address to locate the function with the problem
[8 Oct 2004 15:11] MySQL Verification Team
Verified with versions 5.0.2-alpha-debug-log and 4.1.6-gamma-debug-log.
Server crashes because MyCC does EXPLAIN SELECT.

So, to reproduce the problem just execute (from any client):

USE mysql;
EXPLAIN SELECT *
  INTO OUTFILE '/tmp/help_topic.txt' 
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
  LINES TERMINATED BY '\r\n' 
  FROM `help_topic`
  LIMIT 10;

Back trace:

(gdb) bt
#0  0x0818d5ff in yyparse (yythd=0x879db30) at sql_yacc.yy:6314
#1  0x08177771 in mysql_parse (thd=0x879db30,
    inBuf=0x87aa880 "explain SELECT *\n  INTO OUTFILE '/tmp/help_topic.txt' \n  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' \n  LINES TERMINATED BY '\\r\\n' \n  FROM `help_topic`\n  LIMIT 10", length=170)
    at sql_parse.cc:4538
#2  0x081708e2 in dispatch_command (command=COM_QUERY, thd=0x879db30,
    packet=0x87954b1 "explain SELECT *\n  INTO OUTFILE '/tmp/help_topic.txt' \n  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' \n  LINES TERMINATED BY '\\r\\n' \n  FROM `help_topic`\n  LIMIT 10", packet_length=171)
    at sql_parse.cc:1517
#3  0x081701c7 in do_command (thd=0x879db30) at sql_parse.cc:1297
#4  0x0816f72c in handle_one_connection (arg=0x879db30) at sql_parse.cc:1033
#5  0x4017414b in pthread_start_thread () from /lib/libpthread.so.0
#6  0x401741df in pthread_start_thread_event () from /lib/libpthread.so.0
#7  0x402df50a in clone () from /lib/libc.so.6
[10 Oct 2004 10:32] Ramil Kalimullin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html