diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2019-06-17 09:56:00 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2019-06-17 18:04:47 +0100 |
commit | 5804bb4ef0acd7ac42e628c2d8c404957dc86cf9 (patch) | |
tree | d8180213953c76959d0a19aeb9c3e688722b23e2 /client | |
parent | 81f60e8adeb241ed845427e0792349f3a05af99b (diff) | |
download | mariadb-git-5804bb4ef0acd7ac42e628c2d8c404957dc86cf9.tar.gz |
MDEV-19750 mysql command wrong encoding
Restore the detection of default charset in command line utilities.
It worked up to 10.1, but was broken by Connector/C.
Moved code for detection of default charset from sql-common/client.c
to mysys, and make command line utilities to use this code if charset
was not specified on the command line.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 4 | ||||
-rw-r--r-- | client/mysqladmin.cc | 3 | ||||
-rw-r--r-- | client/mysqlcheck.c | 6 | ||||
-rw-r--r-- | client/mysqlimport.c | 7 | ||||
-rw-r--r-- | client/mysqlshow.c | 2 |
5 files changed, 17 insertions, 5 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 06bf31e16ce..2247e93ca93 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -40,6 +40,7 @@ #include "my_readline.h" #include <signal.h> #include <violite.h> +#include <my_sys.h> #if defined(USE_LIBEDIT_INTERFACE) && defined(HAVE_LOCALE_H) #include <locale.h> @@ -4701,7 +4702,8 @@ sql_real_connect(char *host,char *database,char *user,char *password, select_limit,max_join_size); mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command); } - + if (!strcmp(default_charset,MYSQL_AUTODETECT_CHARSET_NAME)) + default_charset= (char *)my_default_csname(); mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); if (!do_connect(&mysql, host, user, password, database, diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index ef8cb27e672..a4e06b46d94 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -26,6 +26,7 @@ #include <welcome_copyright_notice.h> #include <my_rnd.h> #include <password.h> +#include <my_sys.h> #define ADMIN_VERSION "9.1" #define MAX_MYSQL_VAR 512 @@ -371,6 +372,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 (!strcmp(default_charset,MYSQL_AUTODETECT_CHARSET_NAME)) + default_charset= (char *)my_default_csname(); mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); error_flags= (myf)(opt_nobeep ? 0 : ME_BELL); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index ae8ddeec59c..42c4cae5621 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -440,8 +440,10 @@ static int get_options(int *argc, char ***argv) else default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME; } - if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) && - !get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME))) + if (!strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME)) + default_charset= (char *)my_default_csname(); + + if (!get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME))) { printf("Unsupported character set: %s\n", default_charset); DBUG_RETURN(1); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 722b23844d9..9d8239fe6db 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -30,6 +30,8 @@ #define IMPORT_VERSION "3.7" #include "client_priv.h" +#include <my_sys.h> + #include "mysql_version.h" #include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ @@ -472,8 +474,9 @@ static MYSQL *db_connect(char *host, char *database, if (opt_default_auth && *opt_default_auth) mysql_options(mysql, MYSQL_DEFAULT_AUTH, opt_default_auth); - - mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset); + if (!strcmp(default_charset,MYSQL_AUTODETECT_CHARSET_NAME)) + default_charset= (char *)my_default_csname(); + mysql_options(mysql, MYSQL_SET_CHARSET_NAME, my_default_csname()); mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_RESET, 0); mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "program_name", "mysqlimport"); diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 3fb2d371f2f..47dc7212ca2 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -135,6 +135,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 (!strcmp(default_charset,MYSQL_AUTODETECT_CHARSET_NAME)) + default_charset= (char *)my_default_csname(); mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); if (opt_plugin_dir && *opt_plugin_dir) |