diff -ur mysql-5.1.34/client/mysql.cc mysql-5.1.34-bug-37274/client/mysql.cc --- mysql-5.1.34/client/mysql.cc 2009-03-31 15:35:30.000000000 +0100 +++ mysql-5.1.34-bug-37274/client/mysql.cc 2009-04-27 03:57:16.000000000 +0100 @@ -4246,9 +4246,21 @@ const char *status_str; char buff[40]; ulonglong id; + int error; MYSQL_RES *result; LINT_INIT(result); + /* Test to see if connection is alive first */ + + if (mysql_ping(&mysql)) + { + error= mysql_errno(&mysql); + if ((error != 0) && (error != CR_SERVER_GONE_ERROR)) + return error; + if ((error == CR_SERVER_GONE_ERROR) && (reconnect())) + return error; + } + tee_puts("--------------", stdout); usage(1); /* Print version */ if (connected)