Commit 66aef256 authored by unknown's avatar unknown
Browse files

Merge ssmith@bk-internal.mysql.com:/home/bk/mysql-4.1

into  mysql.com:/home/stewart/Documents/MySQL/4.1/main

parents bb8d3c4e 72340d67
Loading
Loading
Loading
Loading
+39 −34
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@
#include <stdarg.h>
#include <sys/stat.h>
#include <violite.h>
#include <regex.h>                        /* Our own version of lib */
#include "my_regex.h"                     /* Our own version of lib */
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
@@ -188,7 +188,7 @@ static int got_end_timer= FALSE;
static void timer_output(void);
static ulonglong timer_now(void);

static regex_t ps_re; /* Holds precompiled re for valid PS statements */
static my_regex_t ps_re; /* Holds precompiled re for valid PS statements */
static void ps_init_re(void);
static int ps_match_re(char *);
static char *ps_eprint(int);
@@ -585,6 +585,7 @@ static void die(const char *fmt, ...)
    if (cur_file && cur_file != file_stack)
      fprintf(stderr, "In included file \"%s\": ",
              cur_file->file_name);
    if (start_lineno != 0)
      fprintf(stderr, "At line %u: ", start_lineno);
    vfprintf(stderr, fmt, args);
    fprintf(stderr, "\n");
@@ -618,7 +619,9 @@ static void verbose_msg(const char *fmt, ...)

  va_start(args, fmt);

  fprintf(stderr, "mysqltest: At line %u: ", start_lineno);
  fprintf(stderr, "mysqltest: ");
  if (start_lineno > 0)
    fprintf(stderr, "At line %u: ", start_lineno);
  vfprintf(stderr, fmt, args);
  fprintf(stderr, "\n");
  va_end(args);
@@ -1068,8 +1071,8 @@ static void do_exec(struct st_query *query)
          (query->expected_errno[i].code.errnum == status))
      {
        ok= 1;
        verbose_msg("command \"%s\" failed with expected error: %d",
                    cmd, status);
        DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d",
                            cmd, status));
      }
    }
    if (!ok)
@@ -1354,9 +1357,7 @@ int do_sync_with_master2(long offset)
  int rpl_parse;

  if (!master_pos.file[0])
  {
    die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno);
  }
    die("Calling 'sync_with_master' without calling 'save_master_pos'");
  rpl_parse= mysql_rpl_parse_enabled(mysql);
  mysql_disable_rpl_parse(mysql);

@@ -1366,14 +1367,13 @@ int do_sync_with_master2(long offset)
wait_for_position:

  if (mysql_query(mysql, query_buf))
    die("line %u: failed in %s: %d: %s", start_lineno, query_buf,
	mysql_errno(mysql), mysql_error(mysql));
    die("failed in %s: %d: %s", query_buf, mysql_errno(mysql),
        mysql_error(mysql));

  if (!(last_result= res= mysql_store_result(mysql)))
    die("line %u: mysql_store_result() returned NULL for '%s'", start_lineno,
	query_buf);
    die("mysql_store_result() returned NULL for '%s'", query_buf);
  if (!(row= mysql_fetch_row(res)))
    die("line %u: empty result in %s", start_lineno, query_buf);
    die("empty result in %s", query_buf);
  if (!row[0])
  {
    /*
@@ -1381,10 +1381,7 @@ int do_sync_with_master2(long offset)
      SLAVE has been issued ?
    */
    if (tries++ == 3)
    {
      die("line %u: could not sync with master ('%s' returned NULL)", 
          start_lineno, query_buf);
    }
      die("could not sync with master ('%s' returned NULL)", query_buf);
    sleep(1); /* So at most we will wait 3 seconds and make 4 tries */
    mysql_free_result(res);
    goto wait_for_position;
@@ -1430,10 +1427,9 @@ int do_save_master_pos()
	mysql_errno(mysql), mysql_error(mysql));

  if (!(last_result =res = mysql_store_result(mysql)))
    die("line %u: mysql_store_result() retuned NULL for '%s'", start_lineno,
	query);
    die("mysql_store_result() retuned NULL for '%s'", query);
  if (!(row = mysql_fetch_row(res)))
    die("line %u: empty result in show master status", start_lineno);
    die("empty result in show master status");
  strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1);
  master_pos.pos = strtoul(row[1], (char**) 0, 10);
  mysql_free_result(res); last_result=0;
@@ -2571,7 +2567,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
      fn_format(buff, argument, "", "", 4);
      DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
      if (!(cur_file->file=
            my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
            my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
	die("Could not open %s: errno = %d", buff, errno);
      cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
      break;
@@ -3589,12 +3585,13 @@ static void ps_init_re(void)
    "[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|"
    "[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])";

  int err= regcomp(&ps_re, ps_re_str, (REG_EXTENDED | REG_ICASE | REG_NOSUB),
  int err= my_regcomp(&ps_re, ps_re_str,
                      (REG_EXTENDED | REG_ICASE | REG_NOSUB),
                      &my_charset_latin1);
  if (err)
  {
    char erbuf[100];
    int len= regerror(err, &ps_re, erbuf, sizeof(erbuf));
    int len= my_regerror(err, &ps_re, erbuf, sizeof(erbuf));
    fprintf(stderr, "error %s, %d/%d `%s'\n",
            ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
    exit(1);
@@ -3604,7 +3601,7 @@ static void ps_init_re(void)

static int ps_match_re(char *stmt_str)
{
  int err= regexec(&ps_re, stmt_str, (size_t)0, NULL, 0);
  int err= my_regexec(&ps_re, stmt_str, (size_t)0, NULL, 0);

  if (err == 0)
    return 1;
@@ -3613,7 +3610,7 @@ static int ps_match_re(char *stmt_str)
  else
  {
    char erbuf[100];
    int len= regerror(err, &ps_re, erbuf, sizeof(erbuf));
    int len= my_regerror(err, &ps_re, erbuf, sizeof(erbuf));
    fprintf(stderr, "error %s, %d/%d `%s'\n",
            ps_eprint(err), len, (int)sizeof(erbuf), erbuf);
    exit(1);
@@ -3623,7 +3620,7 @@ static int ps_match_re(char *stmt_str)
static char *ps_eprint(int err)
{
  static char epbuf[100];
  size_t len= regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
  size_t len= my_regerror(REG_ITOA|err, (my_regex_t *)NULL, epbuf, sizeof(epbuf));
  assert(len <= sizeof(epbuf));
  return(epbuf);
}
@@ -3631,7 +3628,7 @@ static char *ps_eprint(int err)

static void ps_free_reg(void)
{
  regfree(&ps_re);
  my_regfree(&ps_re);
}

/****************************************************************************/
@@ -4074,13 +4071,21 @@ int main(int argc, char **argv)
    if (res_info.st_size)
      error|= (RESULT_CONTENT_MISMATCH | RESULT_LENGTH_MISMATCH);
  }
  if (result_file && ds_res.length && !error)
  if (ds_res.length && !error)
  {
    if (result_file)
    {
      if (!record)
        error |= check_result(&ds_res, result_file, q->require_file);
      else
        str_to_file(result_file, ds_res.str, ds_res.length);
    }
    else
    {
      /* Print the result to stdout */
      printf("%s", ds_res.str);
    }
  }
  dynstr_free(&ds_res);

  if (!silent)
+2 −1
Original line number Diff line number Diff line
@@ -680,7 +680,8 @@ sub mtr_mysqladmin_shutdown {
    mtr_add_arg($args, "shutdown");
    # We don't wait for termination of mysqladmin
    my $pid= mtr_spawn($::exe_mysqladmin, $args,
                       "", $::path_manager_log, $::path_manager_log, "");
                       "", $::path_manager_log, $::path_manager_log, "",
                       { append_log_file => 1 });
    $mysql_admin_pids{$pid}= 1;
  }

+98 −66
Original line number Diff line number Diff line
@@ -2,37 +2,35 @@
# -*- cperl -*-

# This is a transformation of the "mysql-test-run" Bourne shell script
# to Perl. This is just an intermediate step, the goal is to rewrite
# the Perl script to C. The complexity of the mysql-test-run script
# makes it a bit hard to write and debug it as a C program directly,
# so this is considered a prototype.
# to Perl. There are reasons this rewrite is not the prettiest Perl
# you have seen
#
# Because of this the Perl coding style may in some cases look a bit
# funny. The rules used are
#   - The original script is huge and for most part uncommented,
#     not even a usage description of the flags.
#
#   - The coding style is as close as possible to the C/C++ MySQL
#     coding standard.
#   - There has been an attempt to write a replacement in C for the
#     original Bourne shell script. It was kind of working but lacked
#     lot of functionality to really be a replacement. Not to redo
#     that mistake and catch all the obscure features of the original
#     script, the rewrite in Perl is more close to the original script
#     meaning it also share some of the ugly parts as well.
#
#   - Where NULL is to be returned, the undefined value is used.
#   - The original intention was that this script was to be a prototype
#     to be the base for a new C version with full functionality. Since
#     then it was decided that the Perl version should replace the
#     Bourne shell version, but the Perl style still reflects the wish
#     to make the Perl to C step easy.
#
#   - Regexp comparisons are simple and can be translated to strcmp
#     and other string functions. To ease this transformation matching
#     is done in the lib "lib/mtr_match.pl", i.e. regular expressions
#     should be avoided in the main program.
# Some coding style from the original intent has been kept
#
#   - The "unless" construct is not to be used. It is the same as "if !".
#
#   - opendir/readdir/closedir is used instead of glob()/<*>.
#   - To make this Perl script easy to alter even for those that not
#     code Perl that often, the coding style is as close as possible to
#     the C/C++ MySQL coding standard.
#
#   - All lists of arguments to send to commands are Perl lists/arrays,
#     not strings we append args to. Within reason, most string
#     concatenation for arguments should be avoided.
#
#   - sprintf() is to be used, within reason, for all string creation.
#     This mtr_add_arg() function is also based on sprintf(), i.e. you
#     use a format string and put the variable argument in the argument
#     list.
#
#   - Functions defined in the main program are not to be prefixed,
#     functions in "library files" are to be prefixed with "mtr_" (for
#     Mysql-Test-Run). There are some exceptions, code that fits best in
@@ -467,6 +465,7 @@ sub command_line_setup () {
  # Read the command line
  # Note: Keep list, and the order, in sync with usage at end of this file

  Getopt::Long::Configure("pass_through");
  GetOptions(
             # Control what engine/variation to run
             'embedded-server'          => \$opt_embedded_server,
@@ -554,7 +553,21 @@ sub command_line_setup () {
    usage("");
  }

  @opt_cases= @ARGV;
  foreach my $arg ( @ARGV )
  {
    if ( $arg =~ /^--skip-/ )
    {
      push(@opt_extra_mysqld_opt, $arg);
    }
    elsif ( $arg =~ /^-/ )
    {
      usage("Invalid option \"$arg\"");
    }
    else
    {
      push(@opt_cases, $arg);
    }
  }

  # --------------------------------------------------------------------------
  # Set the "var/" directory, as it is the base for everything else
@@ -743,47 +756,62 @@ sub command_line_setup () {

  # Put this into a hash, will be a C struct

  $master->[0]->{'path_myddir'}=  "$opt_vardir/master-data";
  $master->[0]->{'path_myerr'}=   "$opt_vardir/log/master.err";
  $master->[0]->{'path_mylog'}=   "$opt_vardir/log/master.log";
  $master->[0]->{'path_mypid'}=   "$opt_vardir/run/master.pid";
  $master->[0]->{'path_mysock'}=  "$opt_tmpdir/master.sock";
  $master->[0]->{'path_myport'}=   $opt_master_myport;
  $master->[0]->{'start_timeout'}= 400; # enough time create innodb tables

  $master->[0]->{'ndbcluster'}= 1; # ndbcluster not started

  $master->[1]->{'path_myddir'}=  "$opt_vardir/master1-data";
  $master->[1]->{'path_myerr'}=   "$opt_vardir/log/master1.err";
  $master->[1]->{'path_mylog'}=   "$opt_vardir/log/master1.log";
  $master->[1]->{'path_mypid'}=   "$opt_vardir/run/master1.pid";
  $master->[1]->{'path_mysock'}=  "$opt_tmpdir/master1.sock";
  $master->[1]->{'path_myport'}=   $opt_master_myport + 1;
  $master->[1]->{'start_timeout'}= 400; # enough time create innodb tables

  $slave->[0]->{'path_myddir'}=   "$opt_vardir/slave-data";
  $slave->[0]->{'path_myerr'}=    "$opt_vardir/log/slave.err";
  $slave->[0]->{'path_mylog'}=    "$opt_vardir/log/slave.log";
  $slave->[0]->{'path_mypid'}=    "$opt_vardir/run/slave.pid";
  $slave->[0]->{'path_mysock'}=   "$opt_tmpdir/slave.sock";
  $slave->[0]->{'path_myport'}=    $opt_slave_myport;
  $slave->[0]->{'start_timeout'}=  400;

  $slave->[1]->{'path_myddir'}=   "$opt_vardir/slave1-data";
  $slave->[1]->{'path_myerr'}=    "$opt_vardir/log/slave1.err";
  $slave->[1]->{'path_mylog'}=    "$opt_vardir/log/slave1.log";
  $slave->[1]->{'path_mypid'}=    "$opt_vardir/run/slave1.pid";
  $slave->[1]->{'path_mysock'}=   "$opt_tmpdir/slave1.sock";
  $slave->[1]->{'path_myport'}=    $opt_slave_myport + 1;
  $slave->[1]->{'start_timeout'}=  300;

  $slave->[2]->{'path_myddir'}=   "$opt_vardir/slave2-data";
  $slave->[2]->{'path_myerr'}=    "$opt_vardir/log/slave2.err";
  $slave->[2]->{'path_mylog'}=    "$opt_vardir/log/slave2.log";
  $slave->[2]->{'path_mypid'}=    "$opt_vardir/run/slave2.pid";
  $slave->[2]->{'path_mysock'}=   "$opt_tmpdir/slave2.sock";
  $slave->[2]->{'path_myport'}=    $opt_slave_myport + 2;
  $slave->[2]->{'start_timeout'}=  300;
  $master->[0]=
  {
   path_myddir   => "$opt_vardir/master-data",
   path_myerr    => "$opt_vardir/log/master.err",
   path_mylog    => "$opt_vardir/log/master.log",
   path_mypid    => "$opt_vardir/run/master.pid",
   path_mysock   => "$opt_tmpdir/master.sock",
   path_myport   =>  $opt_master_myport,
   start_timeout =>  400, # enough time create innodb tables

   ndbcluster    =>  1, # ndbcluster not started
  };

  $master->[1]=
  {
   path_myddir   => "$opt_vardir/master1-data",
   path_myerr    => "$opt_vardir/log/master1.err",
   path_mylog    => "$opt_vardir/log/master1.log",
   path_mypid    => "$opt_vardir/run/master1.pid",
   path_mysock   => "$opt_tmpdir/master1.sock",
   path_myport   => $opt_master_myport + 1,
   start_timeout => 400, # enough time create innodb tables
  };

  $slave->[0]=
  {
   path_myddir   => "$opt_vardir/slave-data",
   path_myerr    => "$opt_vardir/log/slave.err",
   path_mylog    => "$opt_vardir/log/slave.log",
   path_mypid    => "$opt_vardir/run/slave.pid",
   path_mysock   => "$opt_tmpdir/slave.sock",
   path_myport   => $opt_slave_myport,
   start_timeout => 400,
  };

  $slave->[1]=
  {
   path_myddir   => "$opt_vardir/slave1-data",
   path_myerr    => "$opt_vardir/log/slave1.err",
   path_mylog    => "$opt_vardir/log/slave1.log",
   path_mypid    => "$opt_vardir/run/slave1.pid",
   path_mysock   => "$opt_tmpdir/slave1.sock",
   path_myport   => $opt_slave_myport + 1,
   start_timeout => 300,
  };

  $slave->[2]=
  {
   path_myddir   => "$opt_vardir/slave2-data",
   path_myerr    => "$opt_vardir/log/slave2.err",
   path_mylog    => "$opt_vardir/log/slave2.log",
   path_mypid    => "$opt_vardir/run/slave2.pid",
   path_mysock   => "$opt_tmpdir/slave2.sock",
   path_myport   => $opt_slave_myport + 2,
   start_timeout => 300,
  };

  if ( $opt_extern )
  {
@@ -1956,7 +1984,9 @@ sub mysqld_start ($$$$) {
  {
    if ( $pid= mtr_spawn($exe, $args, "",
                         $master->[$idx]->{'path_myerr'},
                         $master->[$idx]->{'path_myerr'}, "") )
                         $master->[$idx]->{'path_myerr'},
                         "",
                         { append_log_file => 1 }) )
    {
      return sleep_until_file_created($master->[$idx]->{'path_mypid'},
                                      $master->[$idx]->{'start_timeout'}, $pid);
@@ -1967,7 +1997,9 @@ sub mysqld_start ($$$$) {
  {
    if ( $pid= mtr_spawn($exe, $args, "",
                         $slave->[$idx]->{'path_myerr'},
                         $slave->[$idx]->{'path_myerr'}, "") )
                         $slave->[$idx]->{'path_myerr'},
                         "",
                         { append_log_file => 1 }) )
    {
      return sleep_until_file_created($slave->[$idx]->{'path_mypid'},
                                      $master->[$idx]->{'start_timeout'}, $pid);
@@ -2197,7 +2229,7 @@ sub run_mysqltest ($) {
  $ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args);

  # ----------------------------------------------------------------------
  # Add args that should not go into the MYSQL_TEST environment var
  # Add arguments that should not go into the MYSQL_TEST env var
  # ----------------------------------------------------------------------

  mtr_add_arg($args, "-R");
+6 −0
Original line number Diff line number Diff line
@@ -179,6 +179,7 @@ source database
echo message echo message

mysqltest: At line 1: Empty variable
mysqltest: At line 1: command "false" failed
mysqltest: At line 1: Missing argument in exec
MySQL
"MySQL"
@@ -300,6 +301,7 @@ mysqltest: At line 1: First argument to dec must be a variable (start with $)
mysqltest: At line 1: End of line junk detected: "1000"
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: Missing arguments to system, nothing to do!
mysqltest: At line 1: system command 'false' failed
test
test2
test3
@@ -343,6 +345,10 @@ mysqltest: At line 1: Wrong column number to replace_column in 'replace_column 1
mysqltest: At line 1: Invalid integer argument "10!"
mysqltest: At line 1: End of line junk detected: "!"
mysqltest: At line 1: Invalid integer argument "a"
Output from mysqltest-x.inc
Output from mysqltest-x.inc
Output from mysqltest-x.inc
mysqltest: Could not open ./non_existing_file.inc: errno = 2
failing_statement;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing_statement' at line 1
failing_statement;
+9 −11
Original line number Diff line number Diff line
@@ -426,9 +426,8 @@ echo ;
# ----------------------------------------------------------------------------

# Illegal use of exec
# Disabled, some shells prints the failed command regardless of pipes
#--error 1
#--exec echo "--exec ';' 2> /dev/null" | $MYSQL_TEST 2>&1
--error 1
--exec echo "--exec false" | $MYSQL_TEST 2>&1

--error 1
--exec echo "--exec " | $MYSQL_TEST 2>&1
@@ -675,9 +674,8 @@ system echo "hej" > /dev/null;
--exec echo "system;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1
# Disabled, some shells prints the failed command regardless of pipes
#--error 1
#--exec echo "system NonExistsinfComamdn 2> /dev/null;" | $MYSQL_TEST 2>&1
--error 1
--exec echo "system false;" | $MYSQL_TEST 2>&1

--disable_abort_on_error
system NonExistsinfComamdn;
@@ -812,11 +810,11 @@ select "a" as col1, "c" as col2;
# ----------------------------------------------------------------------------

# -x <file_name>, use the file specified after -x as the test file
#--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1
#--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1
#--exec $MYSQL_TEST --result_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1
#--error 1
#--exec $MYSQL_TEST -x non_existing_file.inc 2>&1
--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
--error 1
--exec $MYSQL_TEST -x non_existing_file.inc 2>&1


# ----------------------------------------------------------------------------
Loading