summaryrefslogtreecommitdiff
path: root/client/mysql.cc
diff options
context:
space:
mode:
authorTatiana A. Nurnberg <azundris@mysql.com>2009-10-20 11:00:07 -0700
committerTatiana A. Nurnberg <azundris@mysql.com>2009-10-20 11:00:07 -0700
commit3f0d0d0633b121b2d615fe547bcd41518f49e810 (patch)
treeb5d1038169ce7dc60fcd39fa7500908a66394ef9 /client/mysql.cc
parentead175bb07a9101488fa59794900f65e3186a88d (diff)
parent5ef63a4f1c2f1abb81caaec639b962837821000f (diff)
downloadmariadb-git-3f0d0d0633b121b2d615fe547bcd41518f49e810.tar.gz
manual merge of 28141
Diffstat (limited to 'client/mysql.cc')
-rw-r--r--client/mysql.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index d46f18332ab..b76a3d624ab 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1280,21 +1280,35 @@ sig_handler handle_sigint(int sig)
MYSQL *kill_mysql= NULL;
/* terminate if no query being executed, or we already tried interrupting */
- if (!executing_query || interrupted_query)
+ /* terminate if no query being executed, or we already tried interrupting */
+ if (!executing_query || (interrupted_query == 2))
+ {
+ tee_fprintf(stdout, "Ctrl-C -- exit!\n");
goto err;
+ }
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");
goto err;
+ }
+
+ 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));
- mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
+ sprintf(kill_buffer, "KILL %s%lu",
+ (interrupted_query == 1) ? "QUERY " : "",
+ mysql_thread_id(&mysql));
+ tee_fprintf(stdout, "Ctrl-C -- sending \"%s\" to server ...\n", kill_buffer);
+ mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
mysql_close(kill_mysql);
- tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
-
- interrupted_query= 1;
+ tee_fprintf(stdout, "Ctrl-C -- query aborted.\n");
return;