diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 8e108e20299..298521b5aa7 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -45,17 +45,15 @@ static const char *load_default_groups[]= { "mysqlbinlog","client",0 }; void sql_print_error(const char *format, ...); static bool one_database = 0; -static bool force_opt= 0; -static const char* database; -static bool short_form = 0; +static const char* database= 0; +static my_bool force_opt= 0, short_form= 0, remote_opt= 0; static ulonglong offset = 0; static const char* host = 0; static int port = MYSQL_PORT; -static const char* sock= MYSQL_UNIX_ADDR; +static const char* sock= 0; static const char* user = 0; static const char* pass = ""; static ulonglong position = 0; -static bool use_remote = 0; static short binlog_flags = 0; static MYSQL* mysql = NULL; @@ -238,6 +236,9 @@ static struct my_option my_long_options[] = 0, 0}, {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"read-from-remote-server", 'R', "Read binary logs from a MySQL server", + (gptr*) &remote_opt, (gptr*) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + 0, 0}, {"short-form", 's', "Just show the queries, no extra info.", (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -342,22 +343,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'd': one_database = 1; break; - case 'h': - use_remote = 1; - break; - case 'P': - use_remote = 1; - break; case 'p': - use_remote = 1; pass = my_strdup(argument, MYF(0)); break; case 'r': if (!(result_file = my_fopen(argument, O_WRONLY | O_BINARY, MYF(MY_WME)))) exit(1); break; - case 'u': - use_remote = 1; + case 'R': + remote_opt= 1; break; case 'V': print_version(); @@ -396,7 +390,7 @@ static MYSQL* safe_connect() static void dump_log_entries(const char* logname) { - if (use_remote) + if (remote_opt) dump_remote_log_entries(logname); else dump_local_log_entries(logname); @@ -758,7 +752,7 @@ int main(int argc, char** argv) return -1; } - if (use_remote) + if (remote_opt) mysql = safe_connect(); MY_TMPDIR tmpdir; @@ -782,7 +776,7 @@ int main(int argc, char** argv) free_tmpdir(&tmpdir); if (result_file != stdout) my_fclose(result_file, MYF(0)); - if (use_remote) + if (remote_opt) mysql_close(mysql); free_defaults(defaults_argv); my_end(0); diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 22b63146652..e22a37fabfd 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -39,28 +39,28 @@ select "--- Local --" as ""; # --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.001 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.001 # this should not fail but shouldn't produce any working statements --disable_query_log select "--- Broken LOAD DATA --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.002 # this should show almost nothing --disable_query_log select "--- --database --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.001 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.001 # this test for position option --disable_query_log select "--- --position --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --position=27 $MYSQL_TEST_DIR/var/log/master-bin.002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=27 $MYSQL_TEST_DIR/var/log/master-bin.002 # These are tests for remote binlog. # They should return the same as previous test. @@ -76,28 +76,28 @@ select "--- Remote --" as ""; # This is broken now # By the way it seems that remote version fetches all events with name >= master-bin.001 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.001 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.001 # This is broken too --disable_query_log select "--- Broken LOAD DATA --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002 # And this too ! (altough it is documented) --disable_query_log select "--- --database --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.001 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.001 # Strangely but this works --disable_query_log select "--- --position --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002 # clean up drop table t1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 17b98fe45c3..e846976eceb 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -36,6 +36,7 @@ bin_SCRIPTS = @server_scripts@ \ make_win_src_distribution EXTRA_SCRIPTS = make_binary_distribution.sh \ + make_sharedlib_distribution.sh \ make_win_src_distribution.sh \ msql2mysql.sh \ mysql_config.sh \ @@ -60,12 +61,13 @@ EXTRA_DIST = $(EXTRA_SCRIPTS) \ mysqlaccess.conf \ mysqlbug -pkgdata_DATA = make_binary_distribution +pkgdata_DATA = make_binary_distribution make_sharedlib_distribution # mysqlbug should be distributed built so that people can report build # failures with it. CLEANFILES = @server_scripts@ \ make_binary_distribution \ + make_sharedlib_distribution \ msql2mysql \ mysql_config \ mysql_fix_privilege_tables \ diff --git a/scripts/make_sharedlib_distribution.sh b/scripts/make_sharedlib_distribution.sh new file mode 100644 index 00000000000..4104a315296 --- /dev/null +++ b/scripts/make_sharedlib_distribution.sh @@ -0,0 +1,117 @@ +#!/bin/sh +# The default path should be /usr/local + +# Get some info from configure +# chmod +x ./scripts/setsomevars + +machine=@MACHINE_TYPE@ +system=@SYSTEM_TYPE@ +version=@VERSION@ +export machine system version +SOURCE=`pwd` +CP="cp -p" +MV="mv" + +STRIP=1 +DEBUG=0 +SILENT=0 +TMP=/tmp +SUFFIX="" + +parse_arguments() { + for arg do + case "$arg" in + --debug) DEBUG=1;; + --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;; + --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; + --no-strip) STRIP=0 ;; + --silent) SILENT=1 ;; + *) + echo "Unknown argument '$arg'" + exit 1 + ;; + esac + done +} + +parse_arguments "$@" + +BASE=$TMP/my_dist$SUFFIX + +if [ -d $BASE ] ; then + rm -r -f $BASE +fi + +mkdir -p $BASE/lib + +for i in \ + libmysql/.libs/libmysqlclient.so* \ + libmysql_r/.libs/libmysqlclient_r.so* +do + if [ -f $i ] + then + $CP $i $BASE/lib + fi +done + +# Change the distribution to a long descriptive name +NEW_NAME=mysql-shared-$version-$system-$machine$SUFFIX +BASE2=$TMP/$NEW_NAME +rm -r -f $BASE2 +mv $BASE $BASE2 +BASE=$BASE2 + +#if we are debugging, do not do tar/gz +if [ x$DEBUG = x1 ] ; then + exit +fi + +# This is needed to prefer GNU tar instead of tar because tar can't +# always handle long filenames + +PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' ` +which_1 () +{ + for cmd + do + for d in $PATH_DIRS + do + for file in $d/$cmd + do + if test -x $file -a ! -d $file + then + echo $file + exit 0 + fi + done + done + done + exit 1 +} + +# +# Create the result tar file +# + +tar=`which_1 gnutar gtar` +if test "$?" = "1" -o "$tar" = "" +then + tar=tar +fi + +echo "Using $tar to create archive" +cd $TMP + +OPT=cvf +if [ x$SILENT = x1 ] ; then + OPT=cf +fi + +$tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME +cd $SOURCE +echo "Compressing archive" +gzip -9 $NEW_NAME.tar +echo "Removing temporary directory" +rm -r -f $BASE + +echo "$NEW_NAME.tar.gz created" diff --git a/sql/slave.cc b/sql/slave.cc index 10d451a88bc..12698c8eda4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1017,11 +1017,12 @@ static int check_master_version(MYSQL* mysql, MASTER_INFO* mi) BINLOG_FORMAT_323_GEQ_57 ; break; case '4': - case '5': mi->old_format = BINLOG_FORMAT_CURRENT; break; default: - errmsg = "Master reported unrecognized MySQL version"; + /* 5.0 is not supported */ + errmsg = "Master reported an unrecognized MySQL version. Note that 4.0 \ +slaves can't replicate a 5.0 or newer master."; break; }