Bug #41487 select into outfile not enclosing integer columns where this would disambiguate
Submitted: 16 Dec 2008 5:27 Modified: 16 Dec 2008 16:20
Reporter: Stewart Smith Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:6.0.9, 5.0, 5.1, 6.0 bzr OS:Any
Assigned to: CPU Architecture:Any

[16 Dec 2008 5:27] Stewart Smith
Description:
This is MySQL and Drizzle... but MySQL just warns and gives you crap (that you can't import).

produces un-readable result file when there is a way (with the syntax specified) to have an un-ambiguous result.

also see https://bugs.launchpad.net/drizzle/+bug/308440

How to repeat:
mysql> create table t1 (a int, b int);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values (42, 42); Query OK, 1 row affected (0.00 sec)

mysql> select * into outfile '../tmp/bar' fields optionally enclosed by '"' terminated by '0' from t1;
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------------------------------------------------------------------------+
| Warning | 1475 | First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY |
+---------+------+------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> Aborted
stewart@hurricane:~/mysql/6.0/mysql-test$ cat var/tmp/bar
42042

Suggested fix:
If enclosed by was used, this wouldn't be ambiguous. Only if enclosed by was something that could be displayed in a number would this be an issue.
[16 Dec 2008 5:30] Stewart Smith
See also http://bugs.mysql.com/bug.php?id=31663
[16 Dec 2008 16:20] Sveta Smirnova
Verified as described.

Problem is repeatable since version 5.0 (and not repeatable with 4.1)