mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Manual merge from mysql-trunk-merge.
This commit is contained in:
@ -1281,21 +1281,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;
|
||||
|
||||
|
Reference in New Issue
Block a user