@@ -141,7 +141,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
141141 vertical=0 , line_numbers=1 , column_names=1 ,opt_html=0 ,
142142 opt_xml=0 ,opt_nopager=1 , opt_outfile=0 , named_cmds= 0 ,
143143 tty_password= 0 , opt_nobeep=0 , opt_reconnect=1 ,
144- default_charset_used= 0 , opt_secure_auth= 0 ,
144+ opt_secure_auth= 0 ,
145145 default_pager_set= 0 , opt_sigint_ignore= 0 ,
146146 show_warnings= 0 , executing_query= 0 , interrupted_query= 0 ,
147147 ignore_spaces= 0 ;
@@ -155,7 +155,7 @@ static char * opt_mysql_unix_port=0;
155155static int connect_flag=CLIENT_INTERACTIVE;
156156static char *current_host,*current_db,*current_user=0 ,*opt_password=0 ,
157157 *current_prompt=0 , *delimiter_str= 0 ,
158- *default_charset= (char *) MYSQL_DEFAULT_CHARSET_NAME ,
158+ *default_charset= (char *) MYSQL_AUTODETECT_CHARSET_NAME ,
159159 *opt_init_command= 0 ;
160160static char *histfile;
161161static char *histfile_tmp;
@@ -1581,9 +1581,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
15811581 strmake (mysql_charsets_dir, argument, sizeof (mysql_charsets_dir) - 1 );
15821582 charsets_dir = mysql_charsets_dir;
15831583 break ;
1584- case OPT_DEFAULT_CHARSET:
1585- default_charset_used= 1 ;
1586- break ;
15871584 case OPT_DELIMITER:
15881585 if (argument == disabled_my_option)
15891586 {
@@ -1788,10 +1785,6 @@ static int get_options(int argc, char **argv)
17881785 connect_flag= 0 ; /* Not in interactive mode */
17891786 }
17901787
1791- if (strcmp (default_charset, charset_info->csname ) &&
1792- !(charset_info= get_charset_by_csname (default_charset,
1793- MY_CS_PRIMARY, MYF (MY_WME))))
1794- exit (1 );
17951788 if (argc > 1 )
17961789 {
17971790 usage (0 );
@@ -2919,7 +2912,6 @@ com_charset(String *buffer __attribute__((unused)), char *line)
29192912 charset_info= new_cs;
29202913 mysql_set_character_set (&mysql, charset_info->csname );
29212914 default_charset= (char *)charset_info->csname ;
2922- default_charset_used= 1 ;
29232915 put_info (" Charset changed" , INFO_INFO);
29242916 }
29252917 else put_info (" Charset is not found" , INFO_INFO);
@@ -4243,8 +4235,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
42434235 select_limit,max_join_size);
42444236 mysql_options (&mysql, MYSQL_INIT_COMMAND, init_command);
42454237 }
4246- if (default_charset_used)
4247- mysql_options (&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
4238+
4239+ mysql_options (&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
4240+
42484241 if (!mysql_real_connect (&mysql, host, user, password,
42494242 database, opt_mysql_port, opt_mysql_unix_port,
42504243 connect_flag | CLIENT_MULTI_STATEMENTS))
@@ -4259,6 +4252,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
42594252 }
42604253 return -1 ; // Retryable
42614254 }
4255+
4256+ charset_info= mysql.charset ;
4257+
42624258 connected=1 ;
42634259#ifndef EMBEDDED_LIBRARY
42644260 mysql.reconnect = debug_info_flag; // We want to know if this happens
0 commit comments