Commit 1bdc15e1 authored by unknown's avatar unknown
Browse files

Add test to mysql-test-run.pl to see if the udf_example.so is availble. Set...

Add test to mysql-test-run.pl to see if the udf_example.so is availble. Set envioronment variable UDF_EXAMPLE_LIB if it is.
Then check in have_udf if that variable is set. Finally use tahe variable when loading the shared library. 


mysql-test/include/have_udf.inc:
  Add check if udf_example.so(or similar) is available
mysql-test/lib/mtr_misc.pl:
  Add funcion "mtr_file_exist" to search for files
mysql-test/mysql-test-run.pl:
  Add checks to find the udf_example.so library
mysql-test/r/udf.result:
  Update result
mysql-test/t/disabled.def:
  Remove udf.test from disabled tests
mysql-test/t/udf.test:
  Use variable UDF_EXAMPLE_LIB when looking for shared library to load
mysql-test/r/have_udf_example.require:
  New BitKeeper file ``mysql-test/r/have_udf_example.require''
parent 2f4f68be
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -6,3 +6,11 @@
disable_query_log;
show variables like "have_dynamic_loading";
enable_query_log;

#
# Check if the variable UDF_EXAMPLE_LIB is set
#
--require r/have_udf_example.require
disable_query_log;
eval select LENGTH("$UDF_EXAMPLE_LIB") > 0 as "have_udf_example_lib";
enable_query_log;
+16 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ sub mtr_init_args ($);
sub mtr_add_arg ($$@);
sub mtr_path_exists(@);
sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@);
sub mtr_copy_dir($$);
sub mtr_same_opts($$);
@@ -94,6 +95,21 @@ sub mtr_script_exists (@) {
  }
}

sub mtr_file_exists (@) {
  foreach my $path ( @_ )
  {
    return $path if -e $path;
  }
  if ( @_ == 1 )
  {
    mtr_error("Could not find $_[0]");
  }
  else
  {
    mtr_error("Could not find any of " . join(" ", @_));
  }
}

sub mtr_exe_exists (@) {
  my @path= @_;
  map {$_.= ".exe"} @path if $::glob_win32;
+4 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ our $exe_mysqltest;
our $exe_slave_mysqld;
our $exe_im;
our $exe_my_print_defaults;
our $lib_udf_example;

our $opt_bench= 0;
our $opt_small_bench= 0;
@@ -1057,6 +1058,8 @@ sub executable_setup () {
      mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables");
    $path_ndb_tools_dir= mtr_path_exists("$glob_basedir/ndb/tools");
    $exe_ndb_mgm=        "$glob_basedir/ndb/src/mgmclient/ndb_mgm";
    $lib_udf_example=
      mtr_file_exists("$glob_basedir/sql/.libs/udf_example.so");
  }
  else
  {
@@ -2936,6 +2939,7 @@ sub run_mysqltest ($) {
  $ENV{'MYSQL_CLIENT_TEST'}=        $cmdline_mysql_client_test;
  $ENV{'CHARSETSDIR'}=              $path_charsetsdir;
  $ENV{'MYSQL_MY_PRINT_DEFAULTS'}=  $exe_my_print_defaults;
  $ENV{'UDF_EXAMPLE_LIB'}=          basename($lib_udf_example);

  $ENV{'NDB_MGM'}=                  $exe_ndb_mgm;
  $ENV{'NDB_BACKUP_DIR'}=           $path_ndb_data_dir;
+2 −0
Original line number Diff line number Diff line
have_udf_example_lib
1
+8 −8
Original line number Diff line number Diff line
drop table if exists t1;
CREATE FUNCTION metaphon RETURNS STRING SONAME 'udf_example.so';
CREATE FUNCTION myfunc_double RETURNS REAL SONAME 'udf_example.so';
CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME 'udf_example.so';
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
ERROR HY000: Can't find function 'myfunc_nonexist' in library
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME 'udf_example.so';
CREATE FUNCTION sequence RETURNS INTEGER SONAME "udf_example.so";
CREATE FUNCTION lookup RETURNS STRING SONAME 'udf_example.so';
CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION sequence RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION lookup RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE FUNCTION reverse_lookup
RETURNS STRING SONAME 'udf_example.so';
RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
CREATE AGGREGATE FUNCTION avgcost
RETURNS REAL SONAME 'udf_example.so';
RETURNS REAL SONAME "UDF_EXAMPLE_LIB";
select myfunc_double();
ERROR HY000: myfunc_double must have at least one argument
select myfunc_double(1);
Loading