Bug #80076 "SELECT... INTO OUTFILE ... CHARACTER SET ucs2" writes non-standard <eol> chars
Description:
"SELECT... INTO OUTFILE ... CHARACTER SET ucs2" generates a file with single-byte '0A' end-of-line characters instead of standard-conformant '00 0A' 16-bit code units.
How to repeat:
Run the following code fragment in MTR environment
****************************************************************************
--let OUTFILE= $MYSQLTEST_VARDIR/tmp/out1.txt
--eval SELECT '00' UNION SELECT '10' INTO OUTFILE '$OUTFILE' CHARACTER SET ucs2
perl;
use strict;
use warnings;
my $filename = $ENV{'OUTFILE'};
my $size = -s $filename;
print "file size: $size\n"
EOF
--remove_file $OUTFILE
****************************************************************************
Output:
****************************************************************************
SELECT '00' UNION SELECT '10' INTO OUTFILE '/home/yura/ws/mysql-build/mysql-test/var/tmp/out1.txt' CHARACTER SET ucs2;
file size: 10
****************************************************************************
The size of the output file is 10 bytes whereas the expected value is 12:
1st line - 2 bytes for the first '0', 2 bytes for the second '0', 2 bytes for <eol>
2nd line - 2 bytes for '1', 2 bytes '0', 2 bytes for <eol>
Although this test was run on Linux, the problem may exist on Windows as well. There, the proper line endings would be '00 0D 00 0A' rather than '0D 0A'.
Suggested fix:
"SELECT... INTO OUTFILE ... CHARACTER SET ucs2" must always write proper <eol> characters to the generated file according to the UCS2 standard.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: "SELECT... INTO OUTFILE ... CHARACTER SET ucs2" generates a file with single-byte '0A' end-of-line characters instead of standard-conformant '00 0A' 16-bit code units. How to repeat: Run the following code fragment in MTR environment **************************************************************************** --let OUTFILE= $MYSQLTEST_VARDIR/tmp/out1.txt --eval SELECT '00' UNION SELECT '10' INTO OUTFILE '$OUTFILE' CHARACTER SET ucs2 perl; use strict; use warnings; my $filename = $ENV{'OUTFILE'}; my $size = -s $filename; print "file size: $size\n" EOF --remove_file $OUTFILE **************************************************************************** Output: **************************************************************************** SELECT '00' UNION SELECT '10' INTO OUTFILE '/home/yura/ws/mysql-build/mysql-test/var/tmp/out1.txt' CHARACTER SET ucs2; file size: 10 **************************************************************************** The size of the output file is 10 bytes whereas the expected value is 12: 1st line - 2 bytes for the first '0', 2 bytes for the second '0', 2 bytes for <eol> 2nd line - 2 bytes for '1', 2 bytes '0', 2 bytes for <eol> Although this test was run on Linux, the problem may exist on Windows as well. There, the proper line endings would be '00 0D 00 0A' rather than '0D 0A'. Suggested fix: "SELECT... INTO OUTFILE ... CHARACTER SET ucs2" must always write proper <eol> characters to the generated file according to the UCS2 standard.