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
16
sql/log.cc
16
sql/log.cc
@ -5261,7 +5261,21 @@ static bool test_if_number(register const char *str,
|
|||||||
|
|
||||||
void sql_perror(const char *message)
|
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));
|
sql_print_error("%s: %s",message, strerror(errno));
|
||||||
#else
|
#else
|
||||||
perror(message);
|
perror(message);
|
||||||
|
@ -8894,7 +8894,7 @@ mysqld_get_one_option(int optid,
|
|||||||
}
|
}
|
||||||
case OPT_EVENT_SCHEDULER:
|
case OPT_EVENT_SCHEDULER:
|
||||||
#ifndef HAVE_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
|
#else
|
||||||
if (Events::set_opt_event_scheduler(argument))
|
if (Events::set_opt_event_scheduler(argument))
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user