mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#20145 perror segfault when call it with error nr
- Add test case(execute perror) - Check if strerror has returned NULL and set msg to "Unknown Error" in that case - Thanks to Steven Xie for pointing out how to fix.
This commit is contained in:
@ -218,8 +218,11 @@ int main(int argc,char *argv[])
|
|||||||
On some system, like NETWARE, strerror(unknown_error) returns a
|
On some system, like NETWARE, strerror(unknown_error) returns a
|
||||||
string 'Unknown Error'. To avoid printing it we try to find the
|
string 'Unknown Error'. To avoid printing it we try to find the
|
||||||
error string by asking for an impossible big error message.
|
error string by asking for an impossible big error message.
|
||||||
|
|
||||||
|
On Solaris 2.8 it might return NULL
|
||||||
*/
|
*/
|
||||||
msg= strerror(10000);
|
if ((msg= strerror(10000)) == NULL)
|
||||||
|
msg= "Unknown Error";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allocate a buffer for unknown_error since strerror always returns
|
Allocate a buffer for unknown_error since strerror always returns
|
||||||
|
@ -187,6 +187,7 @@ our $exe_mysqltest;
|
|||||||
our $exe_slave_mysqld;
|
our $exe_slave_mysqld;
|
||||||
our $exe_im;
|
our $exe_im;
|
||||||
our $exe_my_print_defaults;
|
our $exe_my_print_defaults;
|
||||||
|
our $exe_perror;
|
||||||
our $lib_udf_example;
|
our $lib_udf_example;
|
||||||
our $exe_libtool;
|
our $exe_libtool;
|
||||||
|
|
||||||
@ -1048,6 +1049,8 @@ sub executable_setup () {
|
|||||||
$path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
|
$path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
|
||||||
$exe_my_print_defaults=
|
$exe_my_print_defaults=
|
||||||
mtr_exe_exists("$path_client_bindir/my_print_defaults");
|
mtr_exe_exists("$path_client_bindir/my_print_defaults");
|
||||||
|
$exe_perror=
|
||||||
|
mtr_exe_exists("$path_client_bindir/perror");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1060,6 +1063,8 @@ sub executable_setup () {
|
|||||||
"$glob_basedir/server-tools/instance-manager/mysqlmanager");
|
"$glob_basedir/server-tools/instance-manager/mysqlmanager");
|
||||||
$exe_my_print_defaults=
|
$exe_my_print_defaults=
|
||||||
mtr_exe_exists("$glob_basedir/extra/my_print_defaults");
|
mtr_exe_exists("$glob_basedir/extra/my_print_defaults");
|
||||||
|
$exe_perror=
|
||||||
|
mtr_exe_exists("$glob_basedir/extra/perror");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $glob_use_embedded_server )
|
if ( $glob_use_embedded_server )
|
||||||
@ -1107,6 +1112,8 @@ sub executable_setup () {
|
|||||||
"$glob_basedir/scripts/mysql_fix_privilege_tables");
|
"$glob_basedir/scripts/mysql_fix_privilege_tables");
|
||||||
$exe_my_print_defaults=
|
$exe_my_print_defaults=
|
||||||
mtr_exe_exists("$path_client_bindir/my_print_defaults");
|
mtr_exe_exists("$path_client_bindir/my_print_defaults");
|
||||||
|
$exe_perror=
|
||||||
|
mtr_exe_exists("$path_client_bindir/perror");
|
||||||
|
|
||||||
$path_language= mtr_path_exists("$glob_basedir/share/mysql/english/",
|
$path_language= mtr_path_exists("$glob_basedir/share/mysql/english/",
|
||||||
"$glob_basedir/share/english/");
|
"$glob_basedir/share/english/");
|
||||||
@ -3103,6 +3110,7 @@ sub run_mysqltest ($) {
|
|||||||
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
|
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
|
||||||
$ENV{'UDF_EXAMPLE_LIB'}=
|
$ENV{'UDF_EXAMPLE_LIB'}=
|
||||||
($lib_udf_example ? basename($lib_udf_example) : "");
|
($lib_udf_example ? basename($lib_udf_example) : "");
|
||||||
|
$ENV{'MY_PERROR'}= $exe_perror;
|
||||||
|
|
||||||
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
|
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
|
||||||
$ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir;
|
$ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir;
|
||||||
|
2
mysql-test/r/have_perror.require
Normal file
2
mysql-test/r/have_perror.require
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
have_perror
|
||||||
|
1
|
3
mysql-test/r/perror.result
Normal file
3
mysql-test/r/perror.result
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MySQL error code 150: Foreign key constraint is incorrectly formed
|
||||||
|
Is a named type file
|
||||||
|
Didn't find key on read or update
|
11
mysql-test/t/perror.test
Normal file
11
mysql-test/t/perror.test
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#
|
||||||
|
# Check if the variable MY_PERROR is set
|
||||||
|
#
|
||||||
|
--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 --silent 120
|
||||||
|
|
Reference in New Issue
Block a user