diff options
author | unknown <msvensson@neptunus.(none)> | 2006-07-24 18:05:00 +0200 |
---|---|---|
committer | unknown <msvensson@neptunus.(none)> | 2006-07-24 18:05:00 +0200 |
commit | 0227a7b066bc64a05ab81dc8859227545829a386 (patch) | |
tree | f4a14ddae682a0477f5f3db598ec3c4d7a7ac802 | |
parent | 464cadc99dcfbeda1a814d4a090e10f76f090976 (diff) | |
download | mariadb-git-0227a7b066bc64a05ab81dc8859227545829a386.tar.gz |
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.
extra/perror.c:
strerror might return NULL on Solaris 2.8
mysql-test/mysql-test-run.pl:
Add possibility to execute perror from test case
mysql-test/r/have_perror.require:
New BitKeeper file ``mysql-test/r/have_perror.require''
mysql-test/r/perror.result:
New BitKeeper file ``mysql-test/r/perror.result''
mysql-test/t/perror.test:
New BitKeeper file ``mysql-test/t/perror.test''
-rw-r--r-- | extra/perror.c | 5 | ||||
-rwxr-xr-x | mysql-test/mysql-test-run.pl | 8 | ||||
-rw-r--r-- | mysql-test/r/have_perror.require | 2 | ||||
-rw-r--r-- | mysql-test/r/perror.result | 3 | ||||
-rw-r--r-- | mysql-test/t/perror.test | 11 |
5 files changed, 28 insertions, 1 deletions
diff --git a/extra/perror.c b/extra/perror.c index 82311c1b2c9..531d30dae86 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -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 diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 91a9a758d1d..95ce5dc1bb2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -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; diff --git a/mysql-test/r/have_perror.require b/mysql-test/r/have_perror.require new file mode 100644 index 00000000000..260687c87f0 --- /dev/null +++ b/mysql-test/r/have_perror.require @@ -0,0 +1,2 @@ +have_perror +1 diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result new file mode 100644 index 00000000000..6539955bba6 --- /dev/null +++ b/mysql-test/r/perror.result @@ -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 diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test new file mode 100644 index 00000000000..81847f85c96 --- /dev/null +++ b/mysql-test/t/perror.test @@ -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 + |