mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Bug#34825 perror on windows doesn't know about win32 error codes
extended perror to enable printing of Win32 system errors extra/perror.c: extended perror to enable printing of Win32 system errors mysql-test/r/perror-win.result: test result mysql-test/t/perror-win.test: test case
This commit is contained in:
parent
bc08b15849
commit
fbbdb613d7
3 changed files with 54 additions and 2 deletions
|
@ -185,11 +185,36 @@ static const char *get_ha_error_msg(int code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__WIN__)
|
||||||
|
static my_bool print_win_error_msg(DWORD error, my_bool verbose)
|
||||||
|
{
|
||||||
|
LPTSTR s;
|
||||||
|
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL, error, 0, (LPTSTR)&s, 0,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
printf("Win32 error code %d: %s", error, s);
|
||||||
|
else
|
||||||
|
puts(s);
|
||||||
|
LocalFree(s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
int error,code,found;
|
int error,code,found;
|
||||||
const char *msg;
|
const char *msg;
|
||||||
char *unknown_error = 0;
|
char *unknown_error = 0;
|
||||||
|
#if defined(__WIN__)
|
||||||
|
my_bool skip_win_message= 0;
|
||||||
|
#endif
|
||||||
MY_INIT(argv[0]);
|
MY_INIT(argv[0]);
|
||||||
|
|
||||||
if (get_options(&argc,&argv))
|
if (get_options(&argc,&argv))
|
||||||
|
@ -286,8 +311,15 @@ int main(int argc,char *argv[])
|
||||||
/* Error message still not found, look in handler error codes */
|
/* Error message still not found, look in handler error codes */
|
||||||
if (!(msg=get_ha_error_msg(code)))
|
if (!(msg=get_ha_error_msg(code)))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Illegal error code: %d\n",code);
|
#if defined(__WIN__)
|
||||||
error=1;
|
if (!(skip_win_message= !print_win_error_msg((DWORD)code, verbose)))
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
fprintf(stderr,"Illegal error code: %d\n",code);
|
||||||
|
error=1;
|
||||||
|
#if defined(__WIN__)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -298,6 +330,10 @@ int main(int argc,char *argv[])
|
||||||
puts(msg);
|
puts(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(__WIN__)
|
||||||
|
if (!skip_win_message)
|
||||||
|
print_win_error_msg((DWORD)code, verbose);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
mysql-test/r/perror-win.result
Normal file
5
mysql-test/r/perror-win.result
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
MySQL error code 150: Foreign key constraint is incorrectly formed
|
||||||
|
Win32 error code 150: System trace information was not specified in your CONFIG.SYS file, or tracing is disallowed.
|
||||||
|
OS error code 23: Too many open files in system
|
||||||
|
Win32 error code 23: Data error (cyclic redundancy check).
|
||||||
|
Win32 error code 15000: The specified channel path is invalid.
|
11
mysql-test/t/perror-win.test
Normal file
11
mysql-test/t/perror-win.test
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Windows-specific tests
|
||||||
|
--source include/windows.inc
|
||||||
|
--require r/have_perror.require
|
||||||
|
disable_query_log;
|
||||||
|
eval select LENGTH("$MY_PERROR") > 0 as "have_perror";
|
||||||
|
enable_query_log;
|
||||||
|
|
||||||
|
|
||||||
|
--exec $MY_PERROR 150
|
||||||
|
--exec $MY_PERROR 23
|
||||||
|
--exec $MY_PERROR 15000
|
Loading…
Reference in a new issue