Added options reconnect/enable-reconnect/disable-reconnect/skip-reconnect to the 'mysql' command-line client.
Disabling can be safer when the server silently dies & restarts. This is for SCRUM task #727. client/client_priv.h: Added options reconnect/enable-reconnect/disable-reconnect/skip-reconnect to the 'mysql' command-line client client/mysql.cc: Added options reconnect/enable-reconnect/disable-reconnect/skip-reconnect to the 'mysql' command-line client. Disabling can be safer when the server silently dies & restarts. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
This commit is contained in:
parent
67b5eb7fa0
commit
e376fa6186
@ -67,6 +67,7 @@ mwagner@evoq.mwagner.org
|
|||||||
mwagner@work.mysql.com
|
mwagner@work.mysql.com
|
||||||
nick@mysql.com
|
nick@mysql.com
|
||||||
nick@nick.leippe.com
|
nick@nick.leippe.com
|
||||||
|
papa@gbichot.local
|
||||||
paul@central.snake.net
|
paul@central.snake.net
|
||||||
paul@teton.kitebird.com
|
paul@teton.kitebird.com
|
||||||
pem@mysql.com
|
pem@mysql.com
|
||||||
|
@ -39,4 +39,4 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
|
|||||||
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
|
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
|
||||||
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
|
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
|
||||||
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
|
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
|
||||||
OPT_COMPATIBLE };
|
OPT_COMPATIBLE, OPT_RECONNECT };
|
||||||
|
@ -128,7 +128,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0,
|
|||||||
opt_compress=0, using_opt_local_infile=0,
|
opt_compress=0, using_opt_local_infile=0,
|
||||||
vertical=0, line_numbers=1, column_names=1,opt_html=0,
|
vertical=0, line_numbers=1, column_names=1,opt_html=0,
|
||||||
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
|
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
|
||||||
tty_password= 0, opt_nobeep=0;
|
tty_password= 0, opt_nobeep=0, opt_reconnect=1;
|
||||||
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
|
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
|
||||||
static my_string opt_mysql_unix_port=0;
|
static my_string opt_mysql_unix_port=0;
|
||||||
static int connect_flag=CLIENT_INTERACTIVE;
|
static int connect_flag=CLIENT_INTERACTIVE;
|
||||||
@ -556,6 +556,8 @@ static struct my_option my_long_options[] =
|
|||||||
{"raw", 'r', "Write fields without conversion. Used with --batch",
|
{"raw", 'r', "Write fields without conversion. Used with --batch",
|
||||||
(gptr*) &opt_raw_data, (gptr*) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
(gptr*) &opt_raw_data, (gptr*) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
|
||||||
0, 0, 0},
|
0, 0, 0},
|
||||||
|
{"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.",
|
||||||
|
(gptr*) &opt_reconnect, (gptr*) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||||
{"silent", 's', "Be more silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
|
{"silent", 's', "Be more silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
|
||||||
0, 0},
|
0, 0},
|
||||||
#ifdef HAVE_SMEM
|
#ifdef HAVE_SMEM
|
||||||
@ -783,6 +785,7 @@ static int get_options(int argc, char **argv)
|
|||||||
strmov(pager, "stdout");
|
strmov(pager, "stdout");
|
||||||
opt_nopager= 1;
|
opt_nopager= 1;
|
||||||
opt_outfile= 0;
|
opt_outfile= 0;
|
||||||
|
opt_reconnect= 0;
|
||||||
connect_flag= 0; /* Not in interactive mode */
|
connect_flag= 0; /* Not in interactive mode */
|
||||||
}
|
}
|
||||||
if (default_charset)
|
if (default_charset)
|
||||||
@ -1374,7 +1377,7 @@ char *rindex(const char *s,int c)
|
|||||||
|
|
||||||
static int reconnect(void)
|
static int reconnect(void)
|
||||||
{
|
{
|
||||||
if (!status.batch)
|
if (opt_reconnect)
|
||||||
{
|
{
|
||||||
put_info("No connection. Trying to reconnect...",INFO_INFO);
|
put_info("No connection. Trying to reconnect...",INFO_INFO);
|
||||||
(void) com_connect((String *) 0, 0);
|
(void) com_connect((String *) 0, 0);
|
||||||
@ -1399,7 +1402,7 @@ int mysql_real_query_for_lazy(const char *buf, int length)
|
|||||||
return 0;
|
return 0;
|
||||||
uint error=put_info(mysql_error(&mysql),INFO_ERROR, mysql_errno(&mysql));
|
uint error=put_info(mysql_error(&mysql),INFO_ERROR, mysql_errno(&mysql));
|
||||||
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||
|
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||
|
||||||
status.batch)
|
!opt_reconnect)
|
||||||
return error;
|
return error;
|
||||||
if (reconnect())
|
if (reconnect())
|
||||||
return error;
|
return error;
|
||||||
@ -1584,7 +1587,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
|||||||
if (!connected && reconnect())
|
if (!connected && reconnect())
|
||||||
{
|
{
|
||||||
buffer->length(0); // Remove query on error
|
buffer->length(0); // Remove query on error
|
||||||
return status.batch ? 1 : -1; // Fatal error
|
return opt_reconnect ? -1 : 1; // Fatal error
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
(void) com_print(buffer,0);
|
(void) com_print(buffer,0);
|
||||||
@ -2393,14 +2396,14 @@ com_use(String *buffer __attribute__((unused)), char *line)
|
|||||||
be down during query
|
be down during query
|
||||||
*/
|
*/
|
||||||
if (!connected && reconnect())
|
if (!connected && reconnect())
|
||||||
return status.batch ? 1 : -1; // Fatal error
|
return opt_reconnect ? -1 : 1; // Fatal error
|
||||||
if (mysql_select_db(&mysql,tmp))
|
if (mysql_select_db(&mysql,tmp))
|
||||||
{
|
{
|
||||||
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR)
|
if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR)
|
||||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||||
|
|
||||||
if (reconnect())
|
if (reconnect())
|
||||||
return status.batch ? 1 : -1; // Fatal error
|
return opt_reconnect ? -1 : 1; // Fatal error
|
||||||
if (mysql_select_db(&mysql,tmp))
|
if (mysql_select_db(&mysql,tmp))
|
||||||
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
return put_info(mysql_error(&mysql),INFO_ERROR,mysql_errno(&mysql));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user