Commit 88961a28 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-17710 "unknown error" with FLUSH LOGS if log directory is not writeable

parent 15c79c41
flush logs;
ERROR HY000: Can't create file 'MYSQLTEST_VARDIR/log/mysqld.1.err' (errno: 13 "Permission denied")
flush logs;
source include/not_windows.inc;
source include/not_embedded.inc;
#
# MDEV-17710 "unknown error" with FLUSH LOGS if log directory is not writeable
#
move_file $MYSQLTEST_VARDIR/log/mysqld.1.err $MYSQLTEST_VARDIR/log/mysqld.1.err-bak;
system chmod u-w $MYSQLTEST_VARDIR/log;
replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR;
error ER_CANT_CREATE_FILE;
flush logs;
system chmod u+w $MYSQLTEST_VARDIR/log;
move_file $MYSQLTEST_VARDIR/log/mysqld.1.err-bak $MYSQLTEST_VARDIR/log/mysqld.1.err;
flush logs;
...@@ -8644,14 +8644,14 @@ void sql_perror(const char *message) ...@@ -8644,14 +8644,14 @@ void sql_perror(const char *message)
redirect stdout and stderr to a file. The streams are reopened redirect stdout and stderr to a file. The streams are reopened
only for appending (writing at end of file). only for appending (writing at end of file).
*/ */
extern "C" my_bool reopen_fstreams(const char *filename, bool reopen_fstreams(const char *filename, FILE *outstream, FILE *errstream)
FILE *outstream, FILE *errstream)
{ {
if (outstream && !my_freopen(filename, "a", outstream)) if ((outstream && !my_freopen(filename, "a", outstream)) ||
return TRUE; (errstream && !my_freopen(filename, "a", errstream)))
{
if (errstream && !my_freopen(filename, "a", errstream)) my_error(ER_CANT_CREATE_FILE, MYF(0), filename, errno);
return TRUE; return TRUE;
}
/* The error stream must be unbuffered. */ /* The error stream must be unbuffered. */
if (errstream) if (errstream)
......
...@@ -26,6 +26,7 @@ class Relay_log_info; ...@@ -26,6 +26,7 @@ class Relay_log_info;
class Format_description_log_event; class Format_description_log_event;
bool reopen_fstreams(const char *filename, FILE *outstream, FILE *errstream);
void setup_log_handling(); void setup_log_handling();
bool trans_has_updated_trans_table(const THD* thd); bool trans_has_updated_trans_table(const THD* thd);
bool stmt_has_updated_trans_table(const THD *thd); bool stmt_has_updated_trans_table(const THD *thd);
......
...@@ -209,9 +209,6 @@ typedef fp_except fp_except_t; ...@@ -209,9 +209,6 @@ typedef fp_except fp_except_t;
#define fcntl(X,Y,Z) 0 #define fcntl(X,Y,Z) 0
#endif #endif
extern "C" my_bool reopen_fstreams(const char *filename,
FILE *outstream, FILE *errstream);
inline void setup_fpu() inline void setup_fpu()
{ {
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) #if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT)
......
...@@ -124,14 +124,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, ...@@ -124,14 +124,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
if (options & REFRESH_ERROR_LOG) if (options & REFRESH_ERROR_LOG)
if (unlikely(flush_error_log())) if (unlikely(flush_error_log()))
{
/*
When flush_error_log() failed, my_error() has not been called.
So, we have to do it here to keep the protocol.
*/
my_error(ER_UNKNOWN_ERROR, MYF(0));
result= 1; result= 1;
}
if ((options & REFRESH_SLOW_LOG) && global_system_variables.sql_log_slow) if ((options & REFRESH_SLOW_LOG) && global_system_variables.sql_log_slow)
logger.flush_slow_log(); logger.flush_slow_log();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment