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:
msvensson@neptunus.(none) 2006-07-24 18:05:00 +02:00
parent 2ea50d6d84
commit bbf6c985c8
5 changed files with 28 additions and 1 deletions

View file

@ -218,8 +218,11 @@ int main(int argc,char *argv[])
On some system, like NETWARE, strerror(unknown_error) returns a
string 'Unknown Error'. To avoid printing it we try to find the
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

View file

@ -187,6 +187,7 @@ our $exe_mysqltest;
our $exe_slave_mysqld;
our $exe_im;
our $exe_my_print_defaults;
our $exe_perror;
our $lib_udf_example;
our $exe_libtool;
@ -1048,6 +1049,8 @@ sub executable_setup () {
$path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
$exe_my_print_defaults=
mtr_exe_exists("$path_client_bindir/my_print_defaults");
$exe_perror=
mtr_exe_exists("$path_client_bindir/perror");
}
else
{
@ -1060,6 +1063,8 @@ sub executable_setup () {
"$glob_basedir/server-tools/instance-manager/mysqlmanager");
$exe_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 )
@ -1107,6 +1112,8 @@ sub executable_setup () {
"$glob_basedir/scripts/mysql_fix_privilege_tables");
$exe_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/",
"$glob_basedir/share/english/");
@ -3103,6 +3110,7 @@ sub run_mysqltest ($) {
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
$ENV{'UDF_EXAMPLE_LIB'}=
($lib_udf_example ? basename($lib_udf_example) : "");
$ENV{'MY_PERROR'}= $exe_perror;
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
$ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir;

View file

@ -0,0 +1,2 @@
have_perror
1

View 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
View 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