Fixed sql_perror() to return appropriate error messages on Windows,
The error message is now based on GetLastError() rather than errno. Background: errno is C runtime specific and in many circumstances it is not set, e.g when using Win32 API or socket functions.
This commit is contained in:
parent
79afbf7646
commit
decb9c639a
18
sql/log.cc
18
sql/log.cc
@ -5261,9 +5261,23 @@ static bool test_if_number(register const char *str,
|
||||
|
||||
void sql_perror(const char *message)
|
||||
{
|
||||
#ifdef HAVE_STRERROR
|
||||
#if defined(_WIN32)
|
||||
char* buf;
|
||||
DWORD dw= GetLastError();
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buf, 0, NULL ) > 0)
|
||||
{
|
||||
sql_print_error("%s: %s",message, buf);
|
||||
LocalFree((HLOCAL)buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
sql_print_error("%s", message);
|
||||
}
|
||||
#elif defined(HAVE_STRERROR)
|
||||
sql_print_error("%s: %s",message, strerror(errno));
|
||||
#else
|
||||
#else
|
||||
perror(message);
|
||||
#endif
|
||||
}
|
||||
|
@ -8894,7 +8894,7 @@ mysqld_get_one_option(int optid,
|
||||
}
|
||||
case OPT_EVENT_SCHEDULER:
|
||||
#ifndef HAVE_EVENT_SCHEDULER
|
||||
sql_perror("Event scheduler is not supported in embedded build.");
|
||||
sql_print_error("Event scheduler is not supported in embedded build.");
|
||||
#else
|
||||
if (Events::set_opt_event_scheduler(argument))
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user