@@ -290,7 +290,7 @@ static int com_nopager(String *str, char*), com_pager(String *str, char*),
290290#endif
291291
292292static int read_and_execute (bool interactive);
293- static void init_connection_options (MYSQL *mysql);
293+ static bool init_connection_options (MYSQL *mysql);
294294static int sql_connect (char *host,char *database,char *user,char *password,
295295 uint silent);
296296static const char *server_version_string (MYSQL *mysql);
@@ -5015,7 +5015,12 @@ sql_real_connect(char *host,char *database,char *user,char *password,
50155015 }
50165016
50175017 mysql_init (&mysql);
5018- init_connection_options (&mysql);
5018+ if (init_connection_options (&mysql))
5019+ {
5020+ (void ) put_error (&mysql);
5021+ (void ) fflush (stdout);
5022+ return ignore_errors ? -1 : 1 ; // Abort
5023+ }
50195024
50205025#ifdef _WIN32
50215026 uint cnv_errors;
@@ -5108,7 +5113,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
51085113
51095114
51105115/* Initialize options for the given connection handle. */
5111- static void
5116+ static bool
51125117init_connection_options (MYSQL *mysql)
51135118{
51145119 my_bool handle_expired= (opt_connect_expired_password || !status.batch ) ?
@@ -5151,7 +5156,7 @@ init_connection_options(MYSQL *mysql)
51515156 mysql_options (mysql, MYSQL_INIT_COMMAND, init_command);
51525157 }
51535158
5154- mysql_set_character_set (mysql, default_charset);
5159+ if ( mysql_set_character_set (mysql, default_charset)) return true ;
51555160
51565161 if (opt_plugin_dir && *opt_plugin_dir)
51575162 mysql_options (mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir);
@@ -5170,6 +5175,7 @@ init_connection_options(MYSQL *mysql)
51705175 mysql_options4 (mysql, MYSQL_OPT_CONNECT_ATTR_ADD, " program_name" , " mysql" );
51715176
51725177 mysql_options (mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, &handle_expired);
5178+ return false ;
51735179}
51745180
51755181
0 commit comments