From 284780167d6ad8bcefb087c7c989fdd99992f053 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jan 2005 01:08:45 +0100 Subject: [PATCH 1/8] Change mysqld_safe search for mysqld relative to the current working directory to only look for the mysqld binary (and english error strings) and assume the datadir from that. Then, if that datadir turns out to not exist, startup will fail. This avoids the behavior where mysqld_safe would go off and run a totally different binary because the data directory had been moved (even when --datadir was specified on the command line). (Bug #7249) scripts/mysqld_safe.sh: Don't actually verify that datadir exists when using relatively-located mysqld -- just assume that it does and either let it fail when it doesn't, or do the right thing when datadir is then set via the command line or my.cnf file. --- scripts/mysqld_safe.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 270c08679eb..f6b0169d230 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -86,7 +86,7 @@ parse_arguments() { MY_PWD=`pwd` # Check if we are starting this relative (for the binary release) -if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \ +if test -f ./share/mysql/english/errmsg.sys -a \ -x ./bin/mysqld then MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are @@ -97,7 +97,7 @@ then defaults="--defaults-extra-file=$MY_BASEDIR_VERSION/data/my.cnf" fi # Check if this is a 'moved install directory' -elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \ +elif test -f ./share/mysql/english/errmsg.sys -a \ -x ./libexec/mysqld then MY_BASEDIR_VERSION=$MY_PWD # Where libexec, share and var are From f89207c2e6cbec6e6bf2324a2f9af49bd59fd623 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jan 2005 02:04:12 +0100 Subject: [PATCH 2/8] Make sure to include ZLIB_LIBS in mysql_config --libs_r (Bug #7021) scripts/mysql_config.sh: include ZLIB_LIBS in --libs_r --- scripts/mysql_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 86cbe944416..79d8eef868b 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -88,7 +88,7 @@ client_libs='@CLIENT_LIBS@' libs="$ldflags -L$pkglibdir -lmysqlclient $client_libs" libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` -libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@" +libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @ZLIB_LIBS@ @openssl_libs@" libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` cflags="-I$pkgincludedir @CFLAGS@ " #note: end space! include="-I$pkgincludedir" From 329a6e9c2225096ac7301204cec828d38f30e4a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jan 2005 03:43:37 +0100 Subject: [PATCH 3/8] Protect flags like -Wl,-O2 from being mangled by mysql_config (Bug #6964) (Second commit of this patch -- first included wrong changes.) scripts/mysql_config.sh: Make sure we are only removing whole options (protects -Wl,-O2, for example) --- scripts/mysql_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 86cbe944416..35ddbcac471 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -100,7 +100,7 @@ for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \ DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \ DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*' do - cflags=`echo "$cflags"|sed -e "s/-$remove *//g"` + cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"` done cflags=`echo "$cflags"|sed -e 's/ *\$//'` From 190f7a6f451f01b4b336b8825178ec3e38d24a9c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jan 2005 21:56:18 +0100 Subject: [PATCH 4/8] Fix "mysqladmin password" to use correct password scrambling function when talking to pre-4.1 servers or 4.1 and later servers where the old_passwords option is enabled. "mysqladmin old-password" is unchanged. (Bug #7451) client/mysqladmin.cc: Check old_passwords from server, and use that to determine which scramble function to use (except in the case of the old-password command, which always use the old scramble function). --- client/mysqladmin.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 2e8b3cd588a..6916b4ea808 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -826,13 +826,39 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) if (argv[1][0]) { char *pw= argv[1]; + bool old= find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD; #ifdef __WIN__ uint pw_len= strlen(pw); if (pw_len > 1 && pw[0] == '\'' && pw[pw_len-1] == '\'') printf("Warning: single quotes were not trimmed from the password by" " your command\nline client, as you might have expected.\n"); #endif - if (find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD) + /* + If we don't already know to use an old-style password, see what + the server is using + */ + if (!old) { + if (mysql_query(mysql, "SHOW VARIABLES LIKE 'old_passwords'")) { + my_printf_error(0, "Could not determine old_passwords setting from server; error: '%s'", + MYF(ME_BELL),mysql_error(mysql)); + return -1; + } else { + MYSQL_RES *res= mysql_store_result(mysql); + if (!res) { + my_printf_error(0, "Could not get old_passwords setting from server; error: '%s'", + MYF(ME_BELL),mysql_error(mysql)); + return -1; + } + if (!mysql_num_rows(res)) { + old= 1; + } else { + MYSQL_ROW row= mysql_fetch_row(res); + old= !strncmp(row[1], "ON", 2); + } + mysql_free_result(res); + } + } + if (old) make_scrambled_password_323(crypted_pw, pw); else make_scrambled_password(crypted_pw, pw); From 0f00947b5d219fe252c978cbada03fdb669fac46 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jan 2005 01:08:03 +0100 Subject: [PATCH 5/8] Add support for --default-character-set to mysqladmin (Bug #7524) client/mysqladmin.cc: Handle default-character-set being specified --- client/mysqladmin.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 2e8b3cd588a..ae92765dfdf 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -33,7 +33,8 @@ #define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ #define MAX_TRUNC_LENGTH 3 -char *host= NULL, *user= 0, *opt_password= 0; +char *host= NULL, *user= 0, *opt_password= 0, + *default_charset= NULL; char truncated_var_names[MAX_MYSQL_VAR][MAX_TRUNC_LENGTH]; char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN]; ulonglong last_values[MAX_MYSQL_VAR]; @@ -145,6 +146,9 @@ static struct my_option my_long_options[] = {"character-sets-dir", OPT_CHARSETS_DIR, "Directory where character sets are.", (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"default-character-set", OPT_DEFAULT_CHARSET, + "Set the default character set.", (gptr*) &default_charset, + (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, @@ -343,6 +347,8 @@ int main(int argc,char *argv[]) if (shared_memory_base_name) mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name); #endif + if (default_charset) + mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); if (sql_connect(&mysql, option_wait)) { unsigned int err= mysql_errno(&mysql); From 928c20f8e33512e00d6e5936cfe1c9f206c951dd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jan 2005 19:13:58 +0200 Subject: [PATCH 6/8] fixed comparation with string constant on some platform (BUG#7651) client/mysqldump.c: fixed comparation with string constant on some platform --- client/mysqldump.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 98de9e0b069..da409d44cd1 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -106,7 +106,14 @@ FILE *md_result_file; static char *shared_memory_base_name=0; #endif static uint opt_protocol= 0; -static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET; +/* + Constant for detection default value of default_charset (if + default_charset equal to mysql_universal_client_charset, then it is + default value which assigned in very beginning on main()) +*/ +const static char *mysql_universal_client_charset= + MYSQL_UNIVERSAL_CLIENT_CHARSET; +static char *default_charset; static CHARSET_INFO *charset_info= &my_charset_latin1; const char *default_dbug_option="d:t:o,/tmp/mysqldump.trace"; @@ -678,7 +685,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), Set charset to the default compiled value if it hasn't been reset yet by --default-character-set=xxx. */ - if (default_charset == (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET) + if (default_charset == mysql_universal_client_charset) default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; break; } @@ -2403,6 +2410,7 @@ cleanup: int main(int argc, char **argv) { compatible_mode_normal_str[0]= 0; + default_charset= (char *)mysql_universal_client_charset; MY_INIT(argv[0]); if (get_options(&argc, &argv)) From babb77767a48662fb1c9c80658538b5492a5cc34 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jan 2005 20:47:08 +0200 Subject: [PATCH 7/8] postreview changes client/mysqldump.c: fixed comment fixed compiler warning --- client/mysqldump.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index da409d44cd1..d511dc3bbde 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -107,11 +107,11 @@ static char *shared_memory_base_name=0; #endif static uint opt_protocol= 0; /* - Constant for detection default value of default_charset (if - default_charset equal to mysql_universal_client_charset, then it is - default value which assigned in very beginning on main()) + Constant for detection of default value of default_charset. + If default_charset is equal to mysql_universal_client_charset, then + it is the default value which assigned at the very beginning of main(). */ -const static char *mysql_universal_client_charset= +static const char *mysql_universal_client_charset= MYSQL_UNIVERSAL_CLIENT_CHARSET; static char *default_charset; static CHARSET_INFO *charset_info= &my_charset_latin1; From eb6f4f85f054094d9c6cfd0394d455e7c55a9c57 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Jan 2005 19:57:02 +0100 Subject: [PATCH 8/8] Add comment to make code for option-stripping in mysql_config more clear scripts/mysql_config.sh: Add comment to clarify why we can safely only strip flags with a leading space --- scripts/mysql_config.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 35ddbcac471..3676e03ab48 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -100,6 +100,8 @@ for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \ DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \ DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*' do + # The first option we might strip will always have a space before it because + # we set -I$pkgincludedir as the first option cflags=`echo "$cflags"|sed -e "s/ -$remove */ /g"` done cflags=`echo "$cflags"|sed -e 's/ *\$//'`