Bug #2198 SELECT INTO OUTFILE (with Sub-Select) Problem
Submitted: 23 Dec 2003 11:27 Modified: 19 Jan 2004 5:26
Reporter: Dorn Bhechsonggram Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.1 OS:Linux (Red Hat 7.3)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[23 Dec 2003 11:27] Dorn Bhechsonggram
Description:
When I issue a select statement that contains the sub-select and export into a file, it returns an incorrect results.  

How to repeat:
For instance, SELECT X, (SELECT Y FROM TABLE2 WHERE Z="1") INTO OUTFILE "/tmp/result.txt" FROM TABLE1.  Let say the Y column is DECIMAL(13,3) types and contains the values less than 1 (like 0.0125,etc).  When I excute the statement from CLI, it returns the correct values; however, when I include the INTO OUTFILE options, the Y values return an interger value instead of return decimal values.  Thus, all I get is 0.
[23 Dec 2003 11:47] Dean Ellis
Verified against 4.1.2 with:

CREATE TABLE test ( a int, b decimal(13,3) );
INSERT INTO test VALUES ( 1, 0.123 );
SELECT a, ( SELECT MAX(b) FROM test ) FROM test;
SELECT a, ( SELECT MAX(b) FROM test ) INTO OUTFILE '/tmp/test.out' FROM test;
DROP TABLE test;

Thank you.
[19 Jan 2004 5:26] 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