mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-27142 disable text mode for Windows stdio by default
This avoids LF->CRLF conversion by the C runtime, which historically has been rather buggy (see MDEV-9409) Disabling text mode also fixes the --binary-mode in command line client to work the same on Windows, as it does elsewhere. The user-visible effect is that some text files, e.g output of mysqldump or mysqlbinlog will not have CRLF end-of-lines,but LF. That should be acceptable, as even Notepad can read this Unix EOLs since 2018 (on older Windows, Wordpad can) Leave error log in text(CRLF) mode for now, for the sake of old Windows.
This commit is contained in:
parent
8ee93b9cb4
commit
016dd21371
5 changed files with 19 additions and 44 deletions
|
@ -64,13 +64,8 @@ char *batch_readline(LINE_BUFFER *line_buff, bool binary_mode)
|
|||
return 0;
|
||||
if (out_length && pos[out_length-1] == '\n')
|
||||
{
|
||||
/*
|
||||
On Windows platforms we also need to remove '\r', unconditionally. On
|
||||
Unix-like platforms we only remove it if we are not on binary mode.
|
||||
*/
|
||||
|
||||
/* Remove '\n' */
|
||||
if (--out_length && IF_WIN(1,!binary_mode) && pos[out_length-1] == '\r')
|
||||
if (--out_length && !binary_mode && pos[out_length-1] == '\r')
|
||||
/* Remove '\r' */
|
||||
out_length--;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ RESET MASTER;
|
|||
# It creates the table with a wrong table name and generates an error.
|
||||
# (error output was suppressed to make the test case platform agnostic)
|
||||
|
||||
# It is not in binary_mode, so table name '0x410D0A42' can be translated to
|
||||
# '0x410A42' by mysql depending on the OS - Windows or Unix-like.
|
||||
DROP TABLE `TABLE_NAME_MASKED`;
|
||||
|
||||
# In binary_mode, table name '0x410D0A42' and string '0x410042' can be
|
||||
|
@ -46,5 +44,5 @@ DROP TABLE `A
|
|||
B`;
|
||||
RESET MASTER;
|
||||
include/assert.inc [Table and contents created through mysqltest match 0x610D0A62.]
|
||||
include/assert.inc [Table and contents created while replaying binary log without --binary-mode set match 0x61(0D)0A62.]
|
||||
include/assert.inc [Table and contents created while replaying binary log without --binary-mode set match 0x610A62.]
|
||||
include/assert.inc [Table and contents created while replaying binary log with --binary-mode set match 0x610D0A62.]
|
||||
|
|
|
@ -48,27 +48,15 @@ RESET MASTER;
|
|||
--echo # It creates the table with a wrong table name and generates an error.
|
||||
--echo # (error output was suppressed to make the test case platform agnostic)
|
||||
|
||||
## disabling result log because the error message has the
|
||||
## table name in the output which is one byte different ('\r')
|
||||
## on unixes and windows.
|
||||
|
||||
--disable_result_log
|
||||
--error 1
|
||||
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/my.sql 2>&1
|
||||
--enable_result_log
|
||||
|
||||
--echo
|
||||
--echo # It is not in binary_mode, so table name '0x410D0A42' can be translated to
|
||||
--echo # '0x410A42' by mysql depending on the OS - Windows or Unix-like.
|
||||
--replace_result $table_name_wrong TABLE_NAME_MASKED $table_name_right TABLE_NAME_MASKED
|
||||
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`)
|
||||
{
|
||||
eval DROP TABLE `$table_name_right`;
|
||||
}
|
||||
|
||||
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64', 'Windows')`)
|
||||
{
|
||||
eval DROP TABLE `$table_name_wrong`;
|
||||
}
|
||||
eval DROP TABLE `$table_name_wrong`;
|
||||
|
||||
--echo
|
||||
--echo # In binary_mode, table name '0x410D0A42' and string '0x410042' can be
|
||||
|
@ -150,15 +138,9 @@ RESET MASTER;
|
|||
--let $assert_cond= "$tbl0" = "610D0A62" AND "$val0" = "610D0A62"
|
||||
--source include/assert.inc
|
||||
|
||||
--let $assert_text= Table and contents created while replaying binary log without --binary-mode set match 0x61(0D)0A62.
|
||||
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`)
|
||||
{
|
||||
--let $assert_cond= "$tbl1" = "610D0A62" AND "$val1" = "610D0A62"
|
||||
}
|
||||
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64', 'Windows')`)
|
||||
{
|
||||
--let $assert_cond= "$tbl1" = "610A62" AND "$val1" = "610A62"
|
||||
}
|
||||
--let $assert_text= Table and contents created while replaying binary log without --binary-mode set match 0x610A62.
|
||||
--let $assert_cond= "$tbl1" = "610A62" AND "$val1" = "610A62"
|
||||
|
||||
--source include/assert.inc
|
||||
|
||||
--let $assert_text= Table and contents created while replaying binary log with --binary-mode set match 0x610D0A62.
|
||||
|
|
|
@ -401,16 +401,15 @@ static void my_win_init(void)
|
|||
|
||||
_tzset();
|
||||
|
||||
/*
|
||||
We do not want text translation (LF->CRLF)
|
||||
when stdout is console/terminal, it is buggy
|
||||
*/
|
||||
if (fileno(stdout) >= 0 && isatty(fileno(stdout)))
|
||||
(void)setmode(fileno(stdout), O_BINARY);
|
||||
|
||||
if (fileno(stderr) >= 0 && isatty(fileno(stderr)))
|
||||
(void) setmode(fileno(stderr), O_BINARY);
|
||||
|
||||
/* Disable automatic LF->CRLF translation. */
|
||||
FILE* stdf[]= {stdin, stdout, stderr};
|
||||
for (int i= 0; i < array_elements(stdf); i++)
|
||||
{
|
||||
int fd= fileno(stdf[i]);
|
||||
if (fd >= 0)
|
||||
(void) _setmode(fd, O_BINARY);
|
||||
}
|
||||
_set_fmode(O_BINARY);
|
||||
setup_codepages();
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
|
|
@ -9145,8 +9145,9 @@ void sql_perror(const char *message)
|
|||
*/
|
||||
bool reopen_fstreams(const char *filename, FILE *outstream, FILE *errstream)
|
||||
{
|
||||
if ((outstream && !my_freopen(filename, "a", outstream)) ||
|
||||
(errstream && !my_freopen(filename, "a", errstream)))
|
||||
static constexpr const char *mode= "a" IF_WIN("t", );
|
||||
if ((outstream && !my_freopen(filename, mode, outstream)) ||
|
||||
(errstream && !my_freopen(filename, mode, errstream)))
|
||||
{
|
||||
my_error(ER_CANT_CREATE_FILE, MYF(0), filename, errno);
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue