Below is the list of changes that have just been committed into a local
5.0 repository of tnurnberg. When tnurnberg does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-02-22 15:17:41+01:00, tnurnberg@stripped +2 -0
Bug#28141: Control C on query waiting on lock causes ERROR 1053 (server shutdown)
If a thread is killed in the server, we throw "shutdown" only if one is actually in
progress; otherwise, we throw "query interrupted".
Control-C in the mysql command-line client is "incremental" now.
First Control-C sends KILL QUERY (when connected to 5.0+ server, otherwise, see next)
Next Control-C sends KILL CONNECTION
Next Control-C aborts client.
As the first two steps only pertain to an existing query,
Control-C will abort the client right away if no query is running.
client will give more detailed/consistent feedback on Control-C now.
client/mysql.cc@stripped, 2008-02-22 15:17:39+01:00, tnurnberg@stripped +18 -3
Extends Control-C handling; enhances up feedback to user.
On 5.0+ servers, we try to be nice and send KILL QUERY first
if Control-C is pressed in the command-line client, but if
that doesn't work, we now give the user the opportunity to
send KILL CONNECTION with another Control-C (and to kill the
client with another Control-C if that somehow doesn't work
either).
sql/records.cc@stripped, 2008-02-22 15:17:39+01:00, tnurnberg@stripped +2 -1
Only throw "shutdown" when we have one flagged as being in progress;
otherwise, throw "query interrupted" as it's likely to be "KILL CONNECTION"
or related.
diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc 2008-01-10 18:43:04 +01:00
+++ b/client/mysql.cc 2008-02-22 15:17:39 +01:00
@@ -513,18 +513,33 @@ sig_handler mysql_sigint(int sig)
signal(SIGINT, mysql_sigint);
/* terminate if no query being executed, or we already tried interrupting */
- if (!executing_query || interrupted_query++)
+ if (!executing_query || (interrupted_query == 2))
+ {
+ tee_fprintf(stdout, "Ctrl-C - exit\n");
mysql_end(sig);
+ }
kill_mysql= mysql_init(kill_mysql);
if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
"", opt_mysql_port, opt_mysql_unix_port,0))
+ {
+ tee_fprintf(stdout, "Ctrl-C - sorry, cannot connect to server to kill query, giving up ...\n");
mysql_end(sig);
+ }
+
+ interrupted_query++;
+
+ /* mysqld < 5 does not understand KILL QUERY, skip to KILL CONNECTION */
+ if ((interrupted_query == 1) && (mysql_get_server_version(&mysql) < 50000))
+ interrupted_query= 2;
+
/* kill_buffer is always big enough because max length of %lu is 15 */
- sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
+ sprintf(kill_buffer, "KILL %s %lu",
+ (interrupted_query == 1) ? "QUERY" : "CONNECTION",
+ mysql_thread_id(&mysql));
+ tee_fprintf(stdout, "Ctrl-C - sending \"%s\" to server ...\n", kill_buffer);
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
mysql_close(kill_mysql);
- tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
}
sig_handler mysql_end(int sig)
diff -Nrup a/sql/records.cc b/sql/records.cc
--- a/sql/records.cc 2007-10-17 18:08:53 +02:00
+++ b/sql/records.cc 2008-02-22 15:17:39 +01:00
@@ -225,7 +225,8 @@ static int rr_quick(READ_RECORD *info)
{
if (info->thd->killed)
{
- my_error(ER_SERVER_SHUTDOWN, MYF(0));
+ my_error(shutdown_in_progress ? ER_SERVER_SHUTDOWN
+ : ER_QUERY_INTERRUPTED, MYF(0));
return 1;
}
if (tmp != HA_ERR_RECORD_DELETED)
| Thread |
|---|
| • bk commit into 5.0 tree (tnurnberg:1.2594) BUG#28141 | Tatjana A Nuernberg | 22 Feb |