@@ -131,7 +131,7 @@ typedef enum enum_info_type INFO_TYPE;
131131static MYSQL mysql; /* The connection */
132132static my_bool info_flag=0 ,ignore_errors=0 ,wait_flag=0 ,quick=0 ,
133133 connected=0 ,opt_raw_data=0 ,unbuffered=0 ,output_tables=0 ,
134- rehash =1 ,skip_updates=0 ,safe_updates=0 ,one_database=0 ,
134+ opt_rehash =1 ,skip_updates=0 ,safe_updates=0 ,one_database=0 ,
135135 opt_compress=0 , using_opt_local_infile=0 ,
136136 vertical=0 , line_numbers=1 , column_names=1 ,opt_html=0 ,
137137 opt_xml=0 ,opt_nopager=1 , opt_outfile=0 , named_cmds= 0 ,
@@ -591,7 +591,8 @@ static struct my_option my_long_options[] =
591591#endif
592592 {" auto-rehash" , OPT_AUTO_REHASH ,
593593 " Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash." ,
594- (gptr*) &rehash, (gptr*) &rehash, 0 , GET_BOOL , NO_ARG , 1 , 0 , 0 , 0 , 0 , 0 },
594+ (gptr*) &opt_rehash, (gptr*) &opt_rehash, 0 , GET_BOOL , NO_ARG , 1 , 0 , 0 , 0 ,
595+ 0 , 0 },
595596 {" no-auto-rehash" , ' A' ,
596597 " No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead." ,
597598 0 , 0 , 0 , GET_NO_ARG , NO_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
@@ -898,7 +899,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
898899 }
899900 break ;
900901 case ' A' :
901- rehash = 0 ;
902+ opt_rehash = 0 ;
902903 break ;
903904 case ' N' :
904905 column_names= 0 ;
@@ -1756,15 +1757,17 @@ char *rindex(const char *s,int c)
17561757
17571758static int reconnect (void )
17581759{
1760+ /* purecov: begin tested */
17591761 if (opt_reconnect)
17601762 {
17611763 put_info (" No connection. Trying to reconnect..." ,INFO_INFO );
17621764 (void ) com_connect ((String *) 0 , 0 );
1763- if (rehash )
1765+ if (opt_rehash )
17641766 com_rehash (NULL , NULL );
17651767 }
17661768 if (!connected)
17671769 return put_info (" Can't connect to the server\n " ,INFO_ERROR );
1770+ /* purecov: end */
17681771 return 0 ;
17691772}
17701773
@@ -2933,7 +2936,7 @@ static int
29332936com_connect (String *buffer, char *line)
29342937{
29352938 char *tmp, buff[256 ];
2936- bool save_rehash= rehash ;
2939+ bool save_rehash= opt_rehash ;
29372940 int error;
29382941
29392942 bzero (buff, sizeof (buff));
@@ -2957,13 +2960,16 @@ com_connect(String *buffer, char *line)
29572960 }
29582961 }
29592962 else
2960- rehash= 0 ; // Quick re-connect
2963+ {
2964+ /* Quick re-connect */
2965+ opt_rehash= 0 ; /* purecov: tested */
2966+ }
29612967 buffer->length (0 ); // command used
29622968 }
29632969 else
2964- rehash = 0 ;
2970+ opt_rehash = 0 ;
29652971 error=sql_connect (current_host,current_db,current_user,opt_password,0 );
2966- rehash = save_rehash;
2972+ opt_rehash = save_rehash;
29672973
29682974 if (connected)
29692975 {
@@ -3125,7 +3131,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
31253131 current_db=my_strdup (tmp,MYF (MY_WME ));
31263132#ifdef HAVE_READLINE
31273133 if (select_db > 1 )
3128- build_completion_hash (rehash , 1 );
3134+ build_completion_hash (opt_rehash , 1 );
31293135#endif
31303136 }
31313137
@@ -3279,7 +3285,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
32793285 mysql.reconnect = 1 ;
32803286#endif
32813287#ifdef HAVE_READLINE
3282- build_completion_hash (rehash , 1 );
3288+ build_completion_hash (opt_rehash , 1 );
32833289#endif
32843290 return 0 ;
32853291}
@@ -3324,8 +3330,8 @@ static int
33243330com_status (String *buffer __attribute__ ((unused)),
33253331 char *line __attribute__((unused)))
33263332{
3327- const char *status ;
3328- char buff[22 ];
3333+ const char *status_str ;
3334+ char buff[40 ];
33293335 ulonglong id;
33303336 MYSQL_RES *result;
33313337 LINT_INIT (result);
@@ -3351,9 +3357,9 @@ com_status(String *buffer __attribute__((unused)),
33513357 mysql_free_result (result);
33523358 }
33533359#ifdef HAVE_OPENSSL
3354- if ((status = mysql_get_ssl_cipher (&mysql)))
3360+ if ((status_str = mysql_get_ssl_cipher (&mysql)))
33553361 tee_fprintf (stdout, " SSL:\t\t\t Cipher in use is %s\n " ,
3356- status );
3362+ status_str );
33573363 else
33583364#endif /* HAVE_OPENSSL */
33593365 tee_puts (" SSL:\t\t\t Not in use" , stdout);
@@ -3412,23 +3418,20 @@ com_status(String *buffer __attribute__((unused)),
34123418 tee_fprintf (stdout, " Protocol:\t\t Compressed\n " );
34133419#endif
34143420
3415- if ((status= mysql_stat (&mysql)) && !mysql_error (&mysql)[0 ])
3421+ if ((status_str= mysql_stat (&mysql)) && !mysql_error (&mysql)[0 ])
34163422 {
34173423 ulong sec;
3418- char buff[40 ];
3419- const char *pos= strchr (status,' ' );
3424+ const char *pos= strchr (status_str,' ' );
34203425 /* print label */
3421- tee_fprintf (stdout, " %.*s\t\t\t " , (int ) (pos-status ), status );
3422- if ((status= str2int (pos,10 ,0 ,LONG_MAX ,(long *) &sec)))
3426+ tee_fprintf (stdout, " %.*s\t\t\t " , (int ) (pos-status_str ), status_str );
3427+ if ((status_str= str2int (pos,10 ,0 ,LONG_MAX ,(long *) &sec)))
34233428 {
34243429 nice_time ((double ) sec,buff,0 );
34253430 tee_puts (buff, stdout); /* print nice time */
3426- while (*status == ' ' ) status++; /* to next info */
3427- }
3428- if (status)
3429- {
3431+ while (*status_str == ' ' )
3432+ status_str++; /* to next info */
34303433 tee_putc (' \n ' , stdout);
3431- tee_puts (status , stdout);
3434+ tee_puts (status_str , stdout);
34323435 }
34333436 }
34343437 if (safe_updates)
@@ -3448,7 +3451,7 @@ select_limit, max_join_size);
34483451}
34493452
34503453static const char *
3451- server_version_string (MYSQL *mysql )
3454+ server_version_string (MYSQL *con )
34523455{
34533456 static char buf[MAX_SERVER_VERSION_LENGTH ] = " " ;
34543457
@@ -3458,11 +3461,11 @@ server_version_string(MYSQL *mysql)
34583461 char *bufp = buf;
34593462 MYSQL_RES *result;
34603463
3461- bufp = strnmov (buf, mysql_get_server_info (mysql ), sizeof buf);
3464+ bufp= strnmov (buf, mysql_get_server_info (con ), sizeof buf);
34623465
34633466 /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
3464- if (!mysql_query (mysql , " select @@version_comment limit 1" ) &&
3465- (result = mysql_use_result (mysql )))
3467+ if (!mysql_query (con , " select @@version_comment limit 1" ) &&
3468+ (result = mysql_use_result (con )))
34663469 {
34673470 MYSQL_ROW cur = mysql_fetch_row (result);
34683471 if (cur && cur[0 ])
@@ -3552,10 +3555,10 @@ put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
35523555
35533556
35543557static int
3555- put_error (MYSQL *mysql )
3558+ put_error (MYSQL *con )
35563559{
3557- return put_info (mysql_error (mysql ), INFO_ERROR , mysql_errno (mysql ),
3558- mysql_sqlstate (mysql ));
3560+ return put_info (mysql_error (con ), INFO_ERROR , mysql_errno (con ),
3561+ mysql_sqlstate (con ));
35593562}
35603563
35613564
@@ -3802,8 +3805,6 @@ static const char* construct_prompt()
38023805 break ;
38033806 case ' D' :
38043807 char * dateTime;
3805- time_t lclock;
3806- lclock = time (NULL );
38073808 dateTime = ctime (&lclock);
38083809 processed_prompt.append (strtok (dateTime," \n " ));
38093810 break ;
0 commit comments