Commit e2882676 authored by Mats Kindahl's avatar Mats Kindahl
Browse files

Merging with 5.1-rpl

parents f0bf4a47 f94e914d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -92,7 +92,8 @@ mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
				@CLIENT_EXTRA_LDFLAGS@ \
				$(LIBMYSQLCLIENT_LA) \
				$(top_builddir)/mysys/libmysys.a \
				$(top_builddir)/regex/libregex.a
				$(top_builddir)/regex/libregex.a \
				$(CLIENT_THREAD_LIBS)

mysql_upgrade_SOURCES=          mysql_upgrade.c \
                                $(top_srcdir)/mysys/my_getpagesize.c
+56 −83
Original line number Diff line number Diff line
@@ -269,6 +269,10 @@ get_one_option(int optid, const struct my_option *opt,
}


/**
  Run a command using the shell, storing its output in the supplied dynamic
  string.
*/
static int run_command(char* cmd,
                       DYNAMIC_STRING *ds_res)
{
@@ -341,37 +345,15 @@ static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)
}


/*
  Try to get the full path to this exceutable

  Return 0 if path found

/**
  Look for the filename of given tool, with the presumption that it is in the
  same directory as mysql_upgrade and that the same executable-searching 
  mechanism will be used when we run our sub-shells with popen() later.
*/

static my_bool get_full_path_to_executable(char* path)
static void find_tool(char *tool_executable_name, const char *tool_name, 
                      const char *self_name)
{
  my_bool ret;
  DBUG_ENTER("get_full_path_to_executable");
#ifdef __WIN__
  ret= (GetModuleFileName(NULL, path, FN_REFLEN) == 0);
#else
  /* my_readlink returns 0 if a symlink was read */
  ret= (my_readlink(path, "/proc/self/exe", MYF(0)) != 0);
  /* Might also want to try with /proc/$$/exe if the above fails */
#endif
  DBUG_PRINT("exit", ("path: %s", path));
  DBUG_RETURN(ret);
}


/*
  Look for the tool in the same directory as mysql_upgrade.
*/

static void find_tool(char *tool_path, const char *tool_name)
{
  size_t path_len;
  char path[FN_REFLEN];
  char *last_fn_libchar;
  DYNAMIC_STRING ds_tmp;
  DBUG_ENTER("find_tool");
  DBUG_PRINT("enter", ("progname: %s", my_progname));
@@ -379,36 +361,24 @@ static void find_tool(char *tool_path, const char *tool_name)
  if (init_dynamic_string(&ds_tmp, "", 32, 32))
    die("Out of memory");

  /* Initialize path with the full path to this program */
  if (get_full_path_to_executable(path))
  last_fn_libchar= strrchr(self_name, FN_LIBCHAR);

  if (last_fn_libchar == NULL)
  {
    /*
      Easy way to get full executable path failed, try
      other methods
      mysql_upgrade was found by the shell searching the path.  A sibling
      next to us should be found the same way.
    */
    if (my_progname[0] == FN_LIBCHAR)
    {
      /* 1. my_progname contains full path */
      strmake(path, my_progname, FN_REFLEN);
    }
    else if (my_progname[0] == '.')
    {
      /* 2. my_progname contains relative path, prepend wd */
      char buf[FN_REFLEN];
      my_getwd(buf, FN_REFLEN, MYF(0));
      my_snprintf(path, FN_REFLEN, "%s%s", buf, my_progname);
    strncpy(tool_executable_name, tool_name, FN_REFLEN);
  }
  else
  {
      /* 3. Just go for it and hope tool is in path */
      path[0]= 0;
    }
  }
    int len;

  DBUG_PRINT("info", ("path: '%s'", path));

  /* Chop off binary name (i.e mysql-upgrade) from path */
  dirname_part(path, path, &path_len);
    /*
      mysql_upgrade was run absolutely or relatively.  We can find a sibling
      by replacing our name after the LIBCHAR with the new tool name.
    */

    /*
      When running in a not yet installed build and using libtool,
@@ -418,38 +388,32 @@ static void find_tool(char *tool_path, const char *tool_name)
      mysqlcheck). Thus if path ends in .libs/, step up one directory
      and execute the tools from there
    */
  path[max(path_len-1, 0)]= 0;   /* Chop off last / */
  if (strncmp(path + dirname_length(path), ".libs", 5) == 0)
    if (((last_fn_libchar - 6) >= self_name) &&
        (strncmp(last_fn_libchar - 5, ".libs", 5) == 0) &&
        (*(last_fn_libchar - 6) == FN_LIBCHAR))
    {
    DBUG_PRINT("info", ("Chopping off .libs from '%s'", path));

    /* Chop off .libs */
    dirname_part(path, path, &path_len);
      DBUG_PRINT("info", ("Chopping off \".libs\" from end of path"));
      last_fn_libchar -= 6;
    }

    len= last_fn_libchar - self_name;

  DBUG_PRINT("info", ("path: '%s'", path));

  /* Format name of the tool to search for */
  fn_format(tool_path, tool_name,
            path, "", MYF(MY_REPLACE_DIR));

  verbose("Looking for '%s' in: %s", tool_name, tool_path);
    my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s",
                len, self_name, FN_LIBCHAR, tool_name);
  }

  /* Make sure the tool exists */
  if (my_access(tool_path, F_OK) != 0)
    die("Can't find '%s'", tool_path);
  verbose("Looking for '%s' as: %s", tool_name, tool_executable_name);

  /*
    Make sure it can be executed
  */
  if (run_tool(tool_path,
  if (run_tool(tool_executable_name,
               &ds_tmp, /* Get output from command, discard*/
               "--help",
               "2>&1",
               IF_WIN("> NUL", "> /dev/null"),
               NULL))
    die("Can't execute '%s'", tool_path);
    die("Can't execute '%s'", tool_executable_name);

  dynstr_free(&ds_tmp);

@@ -759,11 +723,20 @@ static const char *load_default_groups[]=

int main(int argc, char **argv)
{
  char self_name[FN_REFLEN];

  MY_INIT(argv[0]);
#ifdef __NETWARE__
  setscreenmode(SCR_AUTOCLOSE_ON_EXIT);
#endif

#if __WIN__
  if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0)
#endif
  {
    strncpy(self_name, argv[0], FN_REFLEN);
  }

  if (init_dynamic_string(&ds_args, "", 512, 256))
    die("Out of memory");

@@ -789,10 +762,10 @@ int main(int argc, char **argv)
  dynstr_append(&ds_args, " ");

  /* Find mysql */
  find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"));
  find_tool(mysql_path, IF_WIN("mysql.exe", "mysql"), self_name);

  /* Find mysqlcheck */
  find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"));
  find_tool(mysqlcheck_path, IF_WIN("mysqlcheck.exe", "mysqlcheck"), self_name);

  /*
    Read the mysql_upgrade_info file to check if mysql_upgrade
+4 −4
Original line number Diff line number Diff line
@@ -343,8 +343,8 @@ case $default_charset in
      default_charset_default_collation="ucs2_general_ci"
      define(UCSC1, ucs2_general_ci ucs2_bin)
      define(UCSC2, ucs2_czech_ci ucs2_danish_ci)
      define(UCSC3, ucs2_esperanto_ci ucs2_estonian_ci ucs2_icelandic_ci)
      define(UCSC4, ucs2_latvian_ci ucs2_lithuanian_ci)
      define(UCSC3, ucs2_esperanto_ci ucs2_estonian_ci ucs2_hungarian_ci)
      define(UCSC4, ucs2_icelandic_ci ucs2_latvian_ci ucs2_lithuanian_ci)
      define(UCSC5, ucs2_persian_ci ucs2_polish_ci ucs2_romanian_ci)
      define(UCSC6, ucs2_slovak_ci ucs2_slovenian_ci)
      define(UCSC7, ucs2_spanish2_ci ucs2_spanish_ci)
@@ -367,8 +367,8 @@ case $default_charset in
      else
        define(UTFC1, utf8_general_ci utf8_bin)
        define(UTFC2, utf8_czech_ci utf8_danish_ci)
        define(UTFC3, utf8_esperanto_ci utf8_estonian_ci utf8_icelandic_ci)
        define(UTFC4, utf8_latvian_ci utf8_lithuanian_ci)
        define(UTFC3, utf8_esperanto_ci utf8_estonian_ci utf8_hungarian_ci)
        define(UTFC4, utf8_icelandic_ci utf8_latvian_ci utf8_lithuanian_ci)
        define(UTFC5, utf8_persian_ci utf8_polish_ci utf8_romanian_ci)
        define(UTFC6, utf8_slovak_ci utf8_slovenian_ci)
        define(UTFC7, utf8_spanish2_ci utf8_spanish_ci)
+40 −16
Original line number Diff line number Diff line
# Test of binlogging of INSERT_ID with INSERT DELAYED
# ==== Purpose ====
#
# Verify that INSERT DELAYED in mixed or row mode writes events to the
# binlog, and that AUTO_INCREMENT works correctly.
#
# ==== Method ====
#
# Insert both single and multiple rows into an autoincrement column,
# both with specified value and with NULL.
#
# With INSERT DELAYED, the rows do not show up in the table
# immediately, so we must do source include/wait_until_rows_count.inc
# between any two INSERT DELAYED statements.  Moreover, if mixed or
# row-based logging is used, there is also a delay between when rows
# show up in the table and when they show up in the binlog.  To ensure
# that the rows show up in the binlog, we call FLUSH TABLES, which
# waits until the delayed_insert thread has finished.
#
# We cannot read the binlog after executing INSERT DELAYED statements
# that insert multiple rows, because that is nondeterministic. More
# precisely, rows may be written in batches to the binlog, where each
# batch has one Table_map_log_event and one or more
# Write_rows_log_event. The number of rows included in each batch is
# nondeterministic.
#
# ==== Related bugs ====
#
# BUG#20627: INSERT DELAYED does not honour auto_increment_* variables
# Bug in this test: BUG#38068: binlog_stm_binlog fails sporadically in pushbuild


create table t1 (a int not null auto_increment, primary key (a)) engine=myisam;
# First, avoid BUG#20627:
set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1;
# Verify that only one INSERT_ID event is binlogged.
# Note, that because of WL#3368 mixed mode binlog records RBR events for the delayed
let $table=t1;
let $rows_inserted=11; # total number of inserted rows in this test
insert delayed into t1 values (207);
let $count=1;

# use this macro instead of sleeps.
let $table=t1;
let $count=0;

insert delayed into t1 values (207);
inc $count;
--source include/wait_until_rows_count.inc

insert delayed into t1 values (null);
inc $count;
--source include/wait_until_rows_count.inc
@@ -20,9 +46,10 @@ insert delayed into t1 values (300);
inc $count;
--source include/wait_until_rows_count.inc

# moving binlog check affront of multi-rows queries which work is indeterministic (extra table_maps)
# todo: better check is to substitute SHOW BINLOG with reading from binlog, probably bug#19459 is in
# the way
# It is not enough to wait until all rows have been inserted into the
# table. FLUSH TABLES ensures that they are in the binlog too.  See
# comment above.
FLUSH TABLES;
source include/show_binlog_events.inc;

insert delayed into t1 values (null),(null),(null),(null);
@@ -33,8 +60,5 @@ insert delayed into t1 values (null),(null),(400),(null);
inc $count; inc $count; inc $count; inc $count;
--source include/wait_until_rows_count.inc

#check this assertion about $count calculation
--echo $count == $rows_inserted

select * from t1;
drop table t1;
+40 −24
Original line number Diff line number Diff line
@@ -309,51 +309,52 @@ sync_slave_with_master;
# 7. Replicating UTF-8 CHAR(255) to CHAR(255) UTF-8

connection master;
CREATE TABLE t1 (i INT NOT NULL,
eval CREATE TABLE t1 (i INT NOT NULL,
                      c CHAR(16) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;

CREATE TABLE t2 (i INT NOT NULL,
eval CREATE TABLE t2 (i INT NOT NULL,
                      c CHAR(16) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;

sync_slave_with_master;
ALTER TABLE t2 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL;

connection master;
CREATE TABLE t3 (i INT NOT NULL,
eval CREATE TABLE t3 (i INT NOT NULL,
                      c CHAR(128) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t3 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL;

connection master;
CREATE TABLE t4 (i INT NOT NULL,
eval CREATE TABLE t4 (i INT NOT NULL,
                      c CHAR(128) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;

CREATE TABLE t5 (i INT NOT NULL,
eval CREATE TABLE t5 (i INT NOT NULL,
                      c CHAR(255) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t5 MODIFY c CHAR(16) CHARACTER SET utf8 NOT NULL;

connection master;
CREATE TABLE t6 (i INT NOT NULL,
eval CREATE TABLE t6 (i INT NOT NULL,
                      c CHAR(255) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;
sync_slave_with_master;
ALTER TABLE t6 MODIFY c CHAR(128) CHARACTER SET utf8 NOT NULL;

connection master;
CREATE TABLE t7 (i INT NOT NULL,
eval CREATE TABLE t7 (i INT NOT NULL,
                      c CHAR(255) CHARACTER SET utf8 NOT NULL,
                 j INT NOT NULL);
                      j INT NOT NULL) ENGINE = $type ;

--echo [expecting slave to replicate correctly]
connection master;
INSERT INTO t1 VALUES (1, "", 1);
INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2);
sync_slave_with_master;

let $diff_table_1=master:test.t1;
let $diff_table_2=slave:test.t1;
@@ -363,6 +364,7 @@ source include/diff_tables.inc;
connection master;
INSERT INTO t2 VALUES (1, "", 1);
INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2);
sync_slave_with_master;

let $diff_table_1=master:test.t2;
let $diff_table_2=slave:test.t2;
@@ -379,7 +381,11 @@ let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8;
connection master;
RESET MASTER;
connection slave;
STOP SLAVE;
RESET SLAVE;
START SLAVE;
source include/wait_for_slave_to_start.inc;

@@ -387,6 +393,7 @@ source include/wait_for_slave_to_start.inc;
connection master;
INSERT INTO t4 VALUES (1, "", 1);
INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2);
sync_slave_with_master;

let $diff_table_1=master:test.t4;
let $diff_table_2=slave:test.t4;
@@ -403,7 +410,11 @@ let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8;
connection master;
RESET MASTER;
connection slave;
STOP SLAVE;
RESET SLAVE;
START SLAVE;
source include/wait_for_slave_to_start.inc;

@@ -418,7 +429,11 @@ let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
disable_query_log;
eval SELECT "$last_error" AS Last_SQL_Error;
enable_query_log;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=8;
connection master;
RESET MASTER;
connection slave;
STOP SLAVE;
RESET SLAVE;
START SLAVE;
source include/wait_for_slave_to_start.inc;

@@ -426,6 +441,7 @@ source include/wait_for_slave_to_start.inc;
connection master;
INSERT INTO t7 VALUES (1, "", 1);
INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2);
sync_slave_with_master;

let $diff_table_1=master:test.t7;
let $diff_table_2=slave:test.t7;
Loading