Bug#37274 client 'status' command doesn't print all info after losing connection to

server

If the server connection was lost during repeated status commands,
the client would fail to detect this and the client output would be inconsistent.

This patch fixes this issue by making sure that the server is online
before the client attempts to execute the status command.
This commit is contained in:
Kristofer Pettersson 2009-07-03 13:55:45 +02:00
parent 5572f8e7de
commit 6455c5689d

View file

@ -4264,17 +4264,18 @@ com_status(String *buffer __attribute__((unused)),
MYSQL_RES *result;
LINT_INIT(result);
if (mysql_real_query_for_lazy(
C_STRING_WITH_LEN("select DATABASE(), USER() limit 1")))
return 0;
tee_puts("--------------", stdout);
usage(1); /* Print version */
if (connected)
{
tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql));
/*
Don't remove "limit 1",
it is protection againts SQL_SELECT_LIMIT=0
*/
if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") &&
(result=mysql_use_result(&mysql)))
if (mysql_store_result_for_lazy(&result))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)
@ -4284,6 +4285,7 @@ com_status(String *buffer __attribute__((unused)),
}
mysql_free_result(result);
}
#ifdef HAVE_OPENSSL
if ((status_str= mysql_get_ssl_cipher(&mysql)))
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
@ -4291,14 +4293,7 @@ com_status(String *buffer __attribute__((unused)),
else
#endif /* HAVE_OPENSSL */
tee_puts("SSL:\t\t\tNot in use", stdout);
}
else
{
vidattr(A_BOLD);
tee_fprintf(stdout, "\nNo connection\n");
vidattr(A_NORMAL);
return 0;
}
if (skip_updates)
{
vidattr(A_BOLD);
@ -4317,8 +4312,14 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff));
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") &&
(result=mysql_use_result(&mysql)))
if (mysql_real_query_for_lazy(C_STRING_WITH_LEN(
"select @@character_set_client, @@character_set_connection, "
"@@character_set_server, @@character_set_database limit 1")))
{
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
return 0;
}
if (mysql_store_result_for_lazy(&result))
{
MYSQL_ROW cur=mysql_fetch_row(result);
if (cur)