From 62683b70fb3a6c386449480dd5f55da690676086 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Jun 2006 14:28:05 +0200 Subject: Improved fix for bug#18516 (also 19353): 1) Rename the old shell tool "mysql_upgrade", to avoid a name collision. 2) Improve the spec file, to explicitly use a temporary socket. scripts/mysql_upgrade_shell.sh: Rename: scripts/mysql_upgrade.sh -> scripts/mysql_upgrade_shell.sh scripts/Makefile.am: The old shell script "mysql_upgrade" must be renamed, so that its name does not collide with the new binary. support-files/mysql.spec.sh: The previous version was incomplete, as it did not cover the case where the DBA had configured a non-default socket file. Solve that by creating and explicitly providing a temporary directory for the socket just for the duration of "mysql_upgrade", which also can be better protected than the default socket. --- scripts/Makefile.am | 6 +- scripts/mysql_upgrade.sh | 203 ----------------------------------------- scripts/mysql_upgrade_shell.sh | 203 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+), 206 deletions(-) delete mode 100644 scripts/mysql_upgrade.sh create mode 100644 scripts/mysql_upgrade_shell.sh (limited to 'scripts') diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 0f68b484f41..a339ebc5b8f 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -32,7 +32,7 @@ bin_SCRIPTS = @server_scripts@ \ mysqldumpslow \ mysql_explain_log \ mysql_tableinfo \ - mysql_upgrade \ + mysql_upgrade_shell \ mysqld_multi \ mysql_create_system_tables @@ -60,7 +60,7 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \ mysql_explain_log.sh \ mysqld_multi.sh \ mysql_tableinfo.sh \ - mysql_upgrade.sh \ + mysql_upgrade_shell.sh \ mysqld_safe.sh \ mysql_create_system_tables.sh @@ -89,7 +89,7 @@ CLEANFILES = @server_scripts@ \ mysqldumpslow \ mysql_explain_log \ mysql_tableinfo \ - mysql_upgrade \ + mysql_upgrade_shell \ mysqld_multi \ make_win_src_distribution \ mysql_create_system_tables diff --git a/scripts/mysql_upgrade.sh b/scripts/mysql_upgrade.sh deleted file mode 100644 index c9f375b6c5b..00000000000 --- a/scripts/mysql_upgrade.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/bin/sh -# Copyright (C) 2002-2003 MySQL AB -# For a more info consult the file COPYRIGHT distributed with this file. - -# Runs mysqlcheck --check-upgrade in case it has not been done on this -# major MySQL version - -# This script should always be run when upgrading from one major version -# to another (ie: 4.1 -> 5.0 -> 5.1) - -# -# Note that in most cases one have to use '--password' as -# arguments as these needs to be passed on to the mysqlcheck command - - -user=root - -case "$1" in - --no-defaults|--defaults-file=*|--defaults-extra-file=*) - defaults="$1"; shift - ;; -esac - -parse_arguments() { - # We only need to pass arguments through to the server if we don't - # handle them here. So, we collect unrecognized options (passed on - # the command line) into the args variable. - pick_args= - if test "$1" = PICK-ARGS-FROM-ARGV - then - pick_args=1 - shift - fi - - for arg do - case "$arg" in - --basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --ldata=*|--data=*|--datadir=*) DATADIR=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; - --force) force=1 ;; - --verbose) verbose=1 ;; - --help) help_option=1 ;; - *) - if test -n "$pick_args" - then - # This sed command makes sure that any special chars are quoted, - # so the arg gets passed exactly to the server. - args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.=-]\),\\\\\1,g'` - fi - ;; - esac - done -} - -# -# Find where my_print_defaults is -# - -find_my_print_defaults () { - if test -x ./bin/my_print_defaults - then - print_defaults="./bin/my_print_defaults" - elif test -x ./extra/my_print_defaults - then - print_defaults="./extra/my_print_defaults" - elif test -x @bindir@/my_print_defaults - then - print_defaults="@bindir@/my_print_defaults" - elif test -x @bindir@/mysql_print_defaults - then - print_defaults="@bindir@/mysql_print_defaults" - else - print_defaults="my_print_defaults" - fi -} - -find_my_print_defaults - -# Get first arguments from the my.cfg file, groups [mysqld] and -# [mysql_upgrade], and then merge with the command line arguments - -args= -DATADIR= -bindir= -MY_BASEDIR_VERSION= -verbose=0 -force=0 -help_option=0 - -parse_arguments `$print_defaults $defaults mysqld mysql_upgrade` -parse_arguments PICK-ARGS-FROM-ARGV "$@" - -if test $help_option = 1 -then - echo "MySQL utility script to upgrade database to the current server version" - echo "" - echo "It takes the following arguments:" - echo " --help Show this help message" - echo " --basedir Specifies the directory where MySQL is installed" - echo " --datadir Specifies the data directory" - echo " --force Mysql_upgrade.info file will be ignored" - echo " --user Username for server login if not current user" - echo " --verbose Display more output about the process" - echo "" - - exit 0 -fi - -# -# Try to find where binaries are installed -# - -MY_PWD=`pwd` -# Check for the directories we would expect from a binary release install -if test -z "$MY_BASEDIR_VERSION" -then - if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld - then - MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are - bindir="$MY_BASEDIR_VERSION/bin" - # Check for the directories we would expect from a source install - elif test -f ./share/mysql/english/errmsg.sys -a -x ./libexec/mysqld - then - MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are - bindir="$MY_BASEDIR_VERSION/bin" -# Since we didn't find anything, used the compiled-in defaults - else - MY_BASEDIR_VERSION=@prefix@ - bindir=@bindir@ - fi -else - bindir="$MY_BASEDIR_VERSION/bin" -fi - -# -# Try to find the data directory -# - -if test -z "$DATADIR" -then - # Try where the binary installs put it - if test -d $MY_BASEDIR_VERSION/data/mysql - then - DATADIR=$MY_BASEDIR_VERSION/data - # Next try where the source installs put it - elif test -d $MY_BASEDIR_VERSION/var/mysql - then - DATADIR=$MY_BASEDIR_VERSION/var - # Or just give up and use our compiled-in default - else - DATADIR=@localstatedir@ - fi -fi - -if test ! -x "$bindir/mysqlcheck" -then - echo "Can't find program '$bindir/mysqlcheck'" - echo "Please restart with --basedir=mysql-install-directory" - exit 1 -fi - -if test ! -f "$DATADIR/mysql/user.frm" -then - echo "Can't find data directory. Please restart with --datadir=path-to-data-dir" - exit 1 -fi - -CHECK_FILE=$DATADIR/mysql_upgrade.info - -if test -f $CHECK_FILE -a $force = 0 -then - version=`cat $CHECK_FILE` - if test "$version" = "@MYSQL_BASE_VERSION@" - then - if test $verbose = 1 - then - echo "mysql_upgrade already done for this version" - fi - $bindir/mysql_fix_privilege_tables --silent $args - exit 0 - fi -fi - -# -# Run the upgrade -# - -check_args="--check-upgrade --all-databases --auto-repair --user=$user" - -if test $verbose = 1 -then - echo "Running $bindir/mysqlcheck $args $check_args" -fi - -$bindir/mysqlcheck $check_args $args -if [ $? = 0 ] -then - # Remember base version so that we don't run this script again on the - # same base version - echo "@MYSQL_BASE_VERSION@" > $CHECK_FILE -fi - -$bindir/mysql_fix_privilege_tables --silent --user=$user $args diff --git a/scripts/mysql_upgrade_shell.sh b/scripts/mysql_upgrade_shell.sh new file mode 100644 index 00000000000..c9f375b6c5b --- /dev/null +++ b/scripts/mysql_upgrade_shell.sh @@ -0,0 +1,203 @@ +#!/bin/sh +# Copyright (C) 2002-2003 MySQL AB +# For a more info consult the file COPYRIGHT distributed with this file. + +# Runs mysqlcheck --check-upgrade in case it has not been done on this +# major MySQL version + +# This script should always be run when upgrading from one major version +# to another (ie: 4.1 -> 5.0 -> 5.1) + +# +# Note that in most cases one have to use '--password' as +# arguments as these needs to be passed on to the mysqlcheck command + + +user=root + +case "$1" in + --no-defaults|--defaults-file=*|--defaults-extra-file=*) + defaults="$1"; shift + ;; +esac + +parse_arguments() { + # We only need to pass arguments through to the server if we don't + # handle them here. So, we collect unrecognized options (passed on + # the command line) into the args variable. + pick_args= + if test "$1" = PICK-ARGS-FROM-ARGV + then + pick_args=1 + shift + fi + + for arg do + case "$arg" in + --basedir=*) MY_BASEDIR_VERSION=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --user=*) user=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --ldata=*|--data=*|--datadir=*) DATADIR=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; + --force) force=1 ;; + --verbose) verbose=1 ;; + --help) help_option=1 ;; + *) + if test -n "$pick_args" + then + # This sed command makes sure that any special chars are quoted, + # so the arg gets passed exactly to the server. + args="$args "`echo "$arg" | sed -e 's,\([^a-zA-Z0-9_.=-]\),\\\\\1,g'` + fi + ;; + esac + done +} + +# +# Find where my_print_defaults is +# + +find_my_print_defaults () { + if test -x ./bin/my_print_defaults + then + print_defaults="./bin/my_print_defaults" + elif test -x ./extra/my_print_defaults + then + print_defaults="./extra/my_print_defaults" + elif test -x @bindir@/my_print_defaults + then + print_defaults="@bindir@/my_print_defaults" + elif test -x @bindir@/mysql_print_defaults + then + print_defaults="@bindir@/mysql_print_defaults" + else + print_defaults="my_print_defaults" + fi +} + +find_my_print_defaults + +# Get first arguments from the my.cfg file, groups [mysqld] and +# [mysql_upgrade], and then merge with the command line arguments + +args= +DATADIR= +bindir= +MY_BASEDIR_VERSION= +verbose=0 +force=0 +help_option=0 + +parse_arguments `$print_defaults $defaults mysqld mysql_upgrade` +parse_arguments PICK-ARGS-FROM-ARGV "$@" + +if test $help_option = 1 +then + echo "MySQL utility script to upgrade database to the current server version" + echo "" + echo "It takes the following arguments:" + echo " --help Show this help message" + echo " --basedir Specifies the directory where MySQL is installed" + echo " --datadir Specifies the data directory" + echo " --force Mysql_upgrade.info file will be ignored" + echo " --user Username for server login if not current user" + echo " --verbose Display more output about the process" + echo "" + + exit 0 +fi + +# +# Try to find where binaries are installed +# + +MY_PWD=`pwd` +# Check for the directories we would expect from a binary release install +if test -z "$MY_BASEDIR_VERSION" +then + if test -f ./share/mysql/english/errmsg.sys -a -x ./bin/mysqld + then + MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are + bindir="$MY_BASEDIR_VERSION/bin" + # Check for the directories we would expect from a source install + elif test -f ./share/mysql/english/errmsg.sys -a -x ./libexec/mysqld + then + MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are + bindir="$MY_BASEDIR_VERSION/bin" +# Since we didn't find anything, used the compiled-in defaults + else + MY_BASEDIR_VERSION=@prefix@ + bindir=@bindir@ + fi +else + bindir="$MY_BASEDIR_VERSION/bin" +fi + +# +# Try to find the data directory +# + +if test -z "$DATADIR" +then + # Try where the binary installs put it + if test -d $MY_BASEDIR_VERSION/data/mysql + then + DATADIR=$MY_BASEDIR_VERSION/data + # Next try where the source installs put it + elif test -d $MY_BASEDIR_VERSION/var/mysql + then + DATADIR=$MY_BASEDIR_VERSION/var + # Or just give up and use our compiled-in default + else + DATADIR=@localstatedir@ + fi +fi + +if test ! -x "$bindir/mysqlcheck" +then + echo "Can't find program '$bindir/mysqlcheck'" + echo "Please restart with --basedir=mysql-install-directory" + exit 1 +fi + +if test ! -f "$DATADIR/mysql/user.frm" +then + echo "Can't find data directory. Please restart with --datadir=path-to-data-dir" + exit 1 +fi + +CHECK_FILE=$DATADIR/mysql_upgrade.info + +if test -f $CHECK_FILE -a $force = 0 +then + version=`cat $CHECK_FILE` + if test "$version" = "@MYSQL_BASE_VERSION@" + then + if test $verbose = 1 + then + echo "mysql_upgrade already done for this version" + fi + $bindir/mysql_fix_privilege_tables --silent $args + exit 0 + fi +fi + +# +# Run the upgrade +# + +check_args="--check-upgrade --all-databases --auto-repair --user=$user" + +if test $verbose = 1 +then + echo "Running $bindir/mysqlcheck $args $check_args" +fi + +$bindir/mysqlcheck $check_args $args +if [ $? = 0 ] +then + # Remember base version so that we don't run this script again on the + # same base version + echo "@MYSQL_BASE_VERSION@" > $CHECK_FILE +fi + +$bindir/mysql_fix_privilege_tables --silent --user=$user $args -- cgit v1.2.1 From 88812ad4abf961ba6455de5d980dcd51888d65a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Jun 2006 12:17:11 +0200 Subject: The binary "mysql_upgrade" must be included in the distribution. (bug#18516 + 19353) scripts/make_binary_distribution.sh: The binary "mysql_upgrade" must be included in the distribution. --- scripts/make_binary_distribution.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 36c941ef6aa..74b1993882e 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -134,7 +134,7 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ client/mysqldump$BS client/mysqlimport$BS \ client/mysqltest$BS client/mysqlcheck$BS \ - client/mysqlbinlog$BS \ + client/mysqlbinlog$BS client/mysql_upgrade$BS \ tests/mysql_client_test$BS \ libmysqld/examples/mysql_client_test_embedded$BS \ libmysqld/examples/mysqltest_embedded$BS \ -- cgit v1.2.1