Bug #58519 SELECT INTO OUTFILE './f' is different from SELECT INTO OUTFILE 'f'
Submitted: 26 Nov 2010 13:20 Modified: 26 Nov 2010 13:38
Reporter: Sven Sandberg Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.0+ OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D2 (Serious)

[26 Nov 2010 13:20] Sven Sandberg
Description:
SELECT INTO OUTFILE 'file' saves the file in the directory of the current database.

SELECT INTO OUTFILE './file' saves the file in @@datadir.

SELECT INTO OUTFILE '../file' or './path/to/file' or '../path/to/file' saves the file in the given directory, relative to @@datadir.

This inconsistency is a bit surprising and it's not documented at http://dev.mysql.com/doc/refman/5.1/en/select.html . Not sure if this is a server bug or a documentation bug.

How to repeat:
==== BEGIN test case ====
USE test;
SELECT 1 INTO OUTFILE '1-1';
SELECT 2 INTO OUTFILE './1-2';
SELECT 3 INTO OUTFILE '../1-3';
==== END test case ====

Run the test case and then 'find . -name 1-*'. This is what I see in 5.1-bugteam:

./var/mysqld.1/1-3
./var/mysqld.1/data/test/1-1
./var/mysqld.1/data/1-2