Bug #16 MySQL 4.1 crashes at SELECT * INTO OUTFILE
Submitted: 29 Dec 2002 15:53 Modified: 12 Mar 2003 10:39
Reporter: Peter Zaitsev (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:MySQL 4.1.0 OS:Any (all)
Assigned to: CPU Architecture:Any

[29 Dec 2002 15:53] Peter Zaitsev
Description:
SELECT * INTO OUTFILE crashes for some tables in MySQL 4.1

How to repeat:
CREATE TABLE t (
  t timestamp NOT NULL,
  c char(200) character set latin1 NOT NULL default '',
  KEY t (t)
) TYPE=MyISAM;

INSERT INTO t VALUES ('2002-12-20 12:01:20','');
INSERT INTO t VALUES ('2002-12-20 12:01:20','');
INSERT INTO t VALUES ('2002-12-20 12:01:20','');
INSERT INTO t VALUES ('2002-12-20 12:01:21','');
INSERT INTO t VALUES ('2002-12-20 12:01:21','');
INSERT INTO t VALUES ('2002-12-20 12:01:21','');
INSERT INTO t VALUES ('2002-12-20 12:01:22','');
INSERT INTO t VALUES ('2002-12-20 12:01:22','');
INSERT INTO t VALUES ('2002-12-20 12:01:22','');
INSERT INTO t VALUES ('2002-12-20 12:01:22','');
INSERT INTO t VALUES ('2002-12-20 12:01:23','');
INSERT INTO t VALUES ('2002-12-20 12:01:23','');
INSERT INTO t VALUES ('2002-12-20 12:01:23','');
INSERT INTO t VALUES ('2002-12-20 12:01:23','');
INSERT INTO t VALUES ('2002-12-20 12:01:24','');
INSERT INTO t VALUES ('2002-12-20 12:01:24','');
INSERT INTO t VALUES ('2002-12-20 12:01:24','');
INSERT INTO t VALUES ('2002-12-20 12:01:25','');
INSERT INTO t VALUES ('2002-12-20 12:01:25','');
INSERT INTO t VALUES ('2002-12-20 12:01:25','');
INSERT INTO t VALUES ('2002-12-20 12:01:25','');
INSERT INTO t VALUES ('2002-12-20 12:01:26','');
INSERT INTO t VALUES ('2002-12-20 12:01:26','');
INSERT INTO t VALUES ('2002-12-20 12:01:26','');
INSERT INTO t VALUES ('2002-12-20 12:01:27','');
INSERT INTO t VALUES ('2002-12-20 12:01:27','');
INSERT INTO t VALUES ('2002-12-20 12:01:27','');
INSERT INTO t VALUES ('2002-12-20 12:01:28','');
INSERT INTO t VALUES ('2002-12-20 12:01:28','');
INSERT INTO t VALUES ('2002-12-20 12:01:28','');
INSERT INTO t VALUES ('2002-12-20 12:01:28','');
INSERT INTO t VALUES ('2002-12-20 12:01:29','');
INSERT INTO t VALUES ('2002-12-20 12:01:29','');
INSERT INTO t VALUES ('2002-12-20 12:01:29','');
INSERT INTO t VALUES ('2002-12-20 12:01:29','');
INSERT INTO t VALUES ('2002-12-20 12:01:30','');
INSERT INTO t VALUES ('2002-12-20 12:01:30','');
INSERT INTO t VALUES ('2002-12-20 12:01:30','');
INSERT INTO t VALUES ('2002-12-20 12:01:31','');
INSERT INTO t VALUES ('2002-12-20 12:01:31','');
INSERT INTO t VALUES ('2002-12-20 12:01:31','');
INSERT INTO t VALUES ('2002-12-20 12:01:31','');
INSERT INTO t VALUES ('2002-12-20 12:01:32','');
INSERT INTO t VALUES ('2002-12-20 12:01:32','');
INSERT INTO t VALUES ('2002-12-20 12:01:32','');

mysql> select * from t into outfile "/tmp/fdg";

Suggested fix:
*** /tmp/field.cc-1.91-17903    Thu Dec 19 13:27:44 2002
--- edited/sql/field.cc Thu Dec 26 20:43:00 2002
***************
*** 2845,2850 ****
--- 2845,2851 ----
    val_buffer->alloc(field_length+1);
    char *to=(char*) val_buffer->ptr(),*end=to+field_length;
    val_buffer->length(field_length);
+   val_buffer->set_charset(val_ptr->charset());
  
  #ifdef WORDS_BIGENDIAN
    if (table->db_low_byte_first)
[12 Mar 2003 10:39] MySQL Verification Team
Finished and pushed.