summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorserg@sergbook.mysql.com <>2005-01-07 14:14:37 +0200
committerserg@sergbook.mysql.com <>2005-01-07 14:14:37 +0200
commit8f104ea83895ab2269b377dfef0d73d5d27a352b (patch)
treeb912263b7fd827acef8c320ff396e9d7ffe7a9e0 /client
parent03f64a63431043689332c6b633990c5bf6b0c535 (diff)
parentd4a62b9c2aca613ffc1e0aa193313b98779908d9 (diff)
downloadmariadb-git-8f104ea83895ab2269b377dfef0d73d5d27a352b.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into sergbook.mysql.com:/usr/home/serg/Abk/mysql-4.1
Diffstat (limited to 'client')
-rw-r--r--client/mysqladmin.cc36
-rw-r--r--client/mysqldump.c12
2 files changed, 44 insertions, 4 deletions
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 2e8b3cd588a..24cd461b1fa 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);
@@ -826,13 +832,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);
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 98de9e0b069..d511dc3bbde 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 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().
+*/
+static const 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))