diff options
author | Alexander Nozdrin <alik@sun.com> | 2009-10-22 22:06:01 +0400 |
---|---|---|
committer | Alexander Nozdrin <alik@sun.com> | 2009-10-22 22:06:01 +0400 |
commit | 564952afb01fa9ff1d6f4622c0f4fb35ccc037cb (patch) | |
tree | 85bcbfa3559990f90ce21638ed46531ed888aaa3 /scripts | |
parent | ffde6bbb15b75c94293784fa0f4264d64039f0b9 (diff) | |
parent | bcaa7524d935464c68e34cb0657cd43517108c40 (diff) | |
download | mariadb-git-564952afb01fa9ff1d6f4622c0f4fb35ccc037cb.tar.gz |
Automerge from mysql-next-mr.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/make_binary_distribution.sh | 8 | ||||
-rwxr-xr-x | scripts/make_win_bin_dist | 1 | ||||
-rw-r--r-- | scripts/mysql_config.sh | 13 | ||||
-rw-r--r-- | scripts/mysql_install_db.sh | 2 | ||||
-rw-r--r-- | scripts/mysqld_safe.sh | 133 |
5 files changed, 155 insertions, 2 deletions
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index bf22267cf42..bd0f4f99ca6 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -64,6 +64,7 @@ cflags="@CFLAGS@" STRIP=1 # Option ignored SILENT=0 +MALLOC_LIB= PLATFORM="" TMP=/tmp NEW_NAME="" # Final top directory and TAR package name @@ -76,6 +77,7 @@ for arg do --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;; --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; --short-product-tag=*) SHORT_PRODUCT_TAG=`echo "$arg" | sed -e "s;--short-product-tag=;;"` ;; + --inject-malloc-lib=*) MALLOC_LIB=`echo "$arg" | sed -e 's;^[^=]*=;;'` ;; --no-strip) STRIP=0 ;; --machine=*) machine=`echo "$arg" | sed -e "s;--machine=;;"` ;; --platform=*) PLATFORM=`echo "$arg" | sed -e "s;--platform=;;"` ;; @@ -293,6 +295,12 @@ if [ x"$BASE_SYSTEM" != x"netware" ] ; then fi fi + # If requested, add a malloc library .so into pkglibdir for use + # by mysqld_safe + if [ -n "$MALLOC_LIB" ]; then + cp "$MALLOC_LIB" "$DEST/lib/" + fi + # FIXME let this script be in "bin/", where it is in the RPMs? # http://dev.mysql.com/doc/refman/5.1/en/mysql-install-db-problems.html mkdir $DEST/scripts diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index ef6ba696300..bf148c45150 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -336,6 +336,7 @@ fi mkdir $DESTDIR/mysql-test cp mysql-test/mysql-test-run.pl $DESTDIR/mysql-test/ +cp mysql-test/mysql-stress-test.pl $DESTDIR/mysql-test/ cp mysql-test/README $DESTDIR/mysql-test/ cp -R mysql-test/{t,r,include,suite,std_data,lib} $DESTDIR/mysql-test/ diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 4118856af19..d2699726a25 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -167,6 +167,10 @@ Options: --port [$port] --version [$version] --libmysqld-libs [$embedded_libs] + --variable=VAR VAR is one of: + pkgincludedir [$pkgincludedir] + pkglibdir [$pkglibdir] + plugindir [$plugindir] EOF exit 1 } @@ -184,6 +188,15 @@ while test $# -gt 0; do --port) echo "$port" ;; --version) echo "$version" ;; --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;; + --variable=*) + var=`echo "$1" | sed 's,^[^=]*=,,'` + case "$var" in + pkgincludedir) echo "$pkgincludedir" ;; + pkglibdir) echo "$pkglibdir" ;; + plugindir) echo "$plugindir" ;; + *) usage ;; + esac + ;; *) usage ;; esac diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 20b7973cb4e..7e9b8a69677 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -313,7 +313,7 @@ then cannot_find_file "$langdir/errmsg.sys" exit 1 fi - mysqld_opt="--language=$langdir" + mysqld_opt="--lc-messages-dir=$langdir/.." fi # Try to determine the hostname diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 23b5efcaf2b..95c4419273f 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -11,9 +11,13 @@ # mysql.server works by first doing a cd to the base directory and from there # executing mysqld_safe +# Initialize script globals KILL_MYSQLD=1; MYSQLD= niceness=0 +mysqld_ld_preload= +mysqld_ld_library_path= + # Initial logging status: error log is not open, and not using syslog logging=init want_syslog=0 @@ -46,6 +50,7 @@ Usage: $0 [OPTIONS] --open-files-limit=LIMIT Limit the number of open files --core-file-size=LIMIT Limit core files to the specified size --timezone=TZ Set the system timezone + --malloc-lib=LIB Preload shared library LIB if available --mysqld=FILE Use the specified file as mysqld --mysqld-version=VERSION Use "mysqld-VERSION" as mysqld --nice=NICE Set the scheduling priority of mysqld @@ -172,6 +177,7 @@ parse_arguments() { # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --core-file-size=*) core_file_size="$val" ;; --ledir=*) ledir="$val" ;; + --malloc-lib=*) set_malloc_lib "$val" ;; --mysqld=*) MYSQLD="$val" ;; --mysqld-version=*) if test -n "$val" @@ -202,6 +208,131 @@ parse_arguments() { } +# Add a single shared library to the list of libraries which will be added to +# LD_PRELOAD for mysqld +# +# Since LD_PRELOAD is a space-separated value (for historical reasons), if a +# shared lib's path contains spaces, that path will be prepended to +# LD_LIBRARY_PATH and stripped from the lib value. +add_mysqld_ld_preload() { + lib_to_add="$1" + log_notice "Adding '$lib_to_add' to LD_PRELOAD for mysqld" + + case "$lib_to_add" in + *' '*) + # Must strip path from lib, and add it to LD_LIBRARY_PATH + lib_file=`basename "$lib_to_add"` + case "$lib_file" in + *' '*) + # The lib file itself has a space in its name, and can't + # be used in LD_PRELOAD + log_error "library name '$lib_to_add' contains spaces and can not be used with LD_PRELOAD" + exit 1 + ;; + esac + lib_path=`dirname "$lib_to_add"` + lib_to_add="$lib_file" + [ -n "$mysqld_ld_library_path" ] && mysqld_ld_library_path="$mysqld_ld_library_path:" + mysqld_ld_library_path="$mysqld_ld_library_path$lib_path" + ;; + esac + + # LD_PRELOAD is a space-separated + [ -n "$mysqld_ld_preload" ] && mysqld_ld_preload="$mysqld_ld_preload " + mysqld_ld_preload="${mysqld_ld_preload}$lib_to_add" +} + + +# Returns LD_PRELOAD (and LD_LIBRARY_PATH, if needed) text, quoted to be +# suitable for use in the eval that calls mysqld. +# +# All values in mysqld_ld_preload are prepended to LD_PRELOAD. +mysqld_ld_preload_text() { + text= + + if [ -n "$mysqld_ld_preload" ]; then + new_text="$mysqld_ld_preload" + [ -n "$LD_PRELOAD" ] && new_text="$new_text $LD_PRELOAD" + text="${text}LD_PRELOAD="`shell_quote_string "$new_text"`' ' + fi + + if [ -n "$mysqld_ld_library_path" ]; then + new_text="$mysqld_ld_library_path" + [ -n "$LD_LIBRARY_PATH" ] && new_text="$new_text:$LD_LIBRARY_PATH" + text="${text}LD_LIBRARY_PATH="`shell_quote_string "$new_text"`' ' + fi + + echo "$text" +} + + +mysql_config= +get_mysql_config() { + if [ -z "$mysql_config" ]; then + mysql_config=`echo "$0" | sed 's,/[^/][^/]*$,/mysql_config,'` + if [ ! -x "$mysql_config" ]; then + log_error "Can not run mysql_config $@ from '$mysql_config'" + exit 1 + fi + fi + + "$mysql_config" "$@" +} + + +# set_malloc_lib LIB +# - If LIB is empty, do nothing and return +# - If LIB is 'tcmalloc', look for tcmalloc shared library in /usr/lib +# then pkglibdir. tcmalloc is part of the Google perftools project. +# - If LIB is an absolute path, assume it is a malloc shared library +# +# Put LIB in mysqld_ld_preload, which will be added to LD_PRELOAD when +# running mysqld. See ld.so for details. +set_malloc_lib() { + malloc_lib="$1" + + if [ "$malloc_lib" = tcmalloc ]; then + pkglibdir=`get_mysql_config --variable=pkglibdir` + malloc_lib= + # This list is kept intentionally simple. Simply set --malloc-lib + # to a full path if another location is desired. + for libdir in /usr/lib "$pkglibdir"; do + for flavor in _minimal '' _and_profiler _debug; do + tmp="$libdir/libtcmalloc$flavor.so" + #log_notice "DEBUG: Checking for malloc lib '$tmp'" + [ -r "$tmp" ] || continue + malloc_lib="$tmp" + break 2 + done + done + + if [ -z "$malloc_lib" ]; then + log_error "no shared library for --malloc-lib=tcmalloc found in /usr/lib or $pkglibdir" + exit 1 + fi + fi + + # Allow --malloc-lib='' to override other settings + [ -z "$malloc_lib" ] && return + + case "$malloc_lib" in + /*) + if [ ! -r "$malloc_lib" ]; then + log_error "--malloc-lib '$malloc_lib' can not be read and will not be used" + exit 1 + fi + ;; + *) + log_error "--malloc-lib must be an absolute path or 'tcmalloc'; " \ + "ignoring value '$malloc_lib'" + exit 1 + ;; + esac + + add_mysqld_ld_preload "$malloc_lib" +} + + # # First, try to find BASEDIR and ledir (where mysqld is) # @@ -549,7 +680,7 @@ fi # ulimit -n 256 > /dev/null 2>&1 # Fix for BSD and FreeBSD systems #fi -cmd="$NOHUP_NICENESS" +cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS" for i in "$ledir/$MYSQLD" "$defaults" "--basedir=$MY_BASEDIR_VERSION" \ "--datadir=$DATADIR" "$USER_OPTION" |